Query your commerce catalog content
Query your commerce catalog content
In most cases, you will want queries originating from a given commerce search interface to target a specific catalog in your Coveo organization. As a result, it will automatically enforce the structure of the catalog configuration and only display products while using the variant and availability attributes for facets.
This will properly scope the catalog, and ensure searches performed on that page are logged in usage analytics.
Prerequisites
Before proceeding, you must:
Step 1: Retrieve the catalog name
To be able to query a given catalog, you must know its unique name.
Access the Catalogs (platform-ca | platform-eu | platform-au) 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.
Method 1: Use a query parameter rule (recommended)
The easiest way to query a catalog is to configure a query pipeline rule that transparently adds the catalog identifier to each query.
-
Access the Query Pipelines (platform-ca | platform-eu | platform-au) page.
-
Double-click the query pipeline used by your search interface.
-
Select the Advanced tab, and then click Query parameters.
-
In the upper-right corner, click Add query parameters rule.
-
In the Add a Query Parameter Rule panel:
-
In the Parameter name field, enter
commerce.catalogId
. -
For the String parameter type, in the Parameter value field, enter the catalog name retrieved in step 1.
-
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.
document.addEventListener("DOMContentLoaded", () => {
// ...
const root = document.getElementById("search");
Coveo.$$(root).on("buildingQuery", (e, args) => {
args.queryBuilder.commerce = { catalogId: "<MY_CATALOG_NAME>" };
});
// ...
Coveo.init(root);
});
Where you would replace <MY_CATALOG_NAME>
with the name of your catalog.
What’s next?
Proceed to Recommended query pipeline configurations.