ShopifyIndexer

ShopifyIndexer indexes Shopify products into a catalog, including automatically resolving the url and imageUrl document fields. It also handles deletion of unavailable products that were previously indexed.

Example

const catalog = await client.getCatalog("shopify-products");
 
const shopifyProductIndexer = catalog.shopifyIndexer({
  shopifyBaseUrl: "https://shopify-store-url.com",
});
 
await shopifyProductIndexer.index();

ShopifyIndexerOpts

type ShopifyIndexerOpts = {
  shopifyBaseUrl: string;
  maxItems?: number;
  batchSize?: number;
};
  • shopifyBaseUrl: The base URL of the Shopify store.
  • maxItems (optional): The maximum number of items to index.
  • batchSize (optional): The number of items to process in each batch (default: 25).

Methods

index()

public async index(): Promise<void>

Indexes the Shopify products into the catalog. This method fetches products from the Shopify API, processes them, and adds them to the catalog. It also handles the deletion of unavailable products.

Usage

const indexer = new ShopifyIndexer(catalog, opts);
await indexer.index();

This method performs the following tasks:

  1. Fetches products from the Shopify API.
  2. Processes each product, extracting relevant information.
  3. Adds available products to the catalog.
  4. Marks unavailable products for deletion.
  5. Respects the maxItems limit if specified.
  6. Indexes the processed products in batches.
  7. Deletes the marked products from the catalog.