Querying Commerce Catalog Content

In most cases, you’ll want queries originating from a given commerce search interface to target a specific catalog in your Coveo Cloud organization.

Prerequisites

Before proceeding on to step 1, you must have:

  1. Indexed commerce catalog content

  2. Created a Coveo commerce catalog

Step 1: Retrieve the Catalog Name

To be able to query a given catalog, you must know its unique name.

Access the Catalogs page, and then locate and copy the desired catalog name from the table.

Step 2: Configure Your Search Interface

Use one of the following methods to ensure that your commerce search interface targets the desired catalog.

The easiest way to query a catalog is to configure a query pipeline rule that transparently adds the catalog identifier to each query.

  1. Access the Query Pipelines page.

  2. Double click the query pipeline used by your search interface.

  3. Select the Query Parameters tab.

  4. In the top-right corner, click Add Rule, and then select Query parameters rule.

  5. In the Add a Query Parameter Rule panel:

    1. In the Parameter name box, enter commerce.catalogId.

    2. In the Parameter value box, enter the catalog name retrieved in step 1.

    3. Click Add Rule.

Queries originating from your commerce search interface will now target the specified catalog.

Method 2: Use a buildingQuery Event Handler

In a JavaScript Search Framework interface, if you would rather modify queries before sending them to the Search API, you can code a buildingQuery event handler that sets the commerce property of the QueryBuilder object as desired (see JavaScript Search Framework Events).

document.addEventListener("DOMContentLoaded", () => {
 
  // ...
 
  const root = document.getElementById("search");
  Coveo.$$(root).on("buildingQuery", (e, args) => {
    args.queryBuilder.commerce = { catalogId: "my-catalog-name" };
  });
 
  // ...
 
  Coveo.init(root);
});
Recommended Articles