How to query product catalogue

You are here:
Estimated reading time: 1 min

If you want to add custom product filters to product recommendations or query the catalogue, here’s a quick overview on how to do it using JSON

What you need to remember is that you need to use your product feed attributes:

{
  "main": false,
  "active": true,
  "prev_price_ch": {
    "exists": true
  }
}

Then for each attribute you will use the following format:

  • attribute: value > when you want to do equal comparison with a specific value
  • attribute: { operator: value} > when you want to use other than a simple equality
    • gte, gt, lte, lt > greater than or equals
    • in: > value if any of the following
    • exists > to check if a field exists

Note that you can use a single operator for every attribute in the dictionary.

Count items

First step is to count items in the catalogue based on your desired filters. This will make sure there will be results with your filters.

If your product catalogue has product variations (like color, size), you should also provide our system what are considered the “main” products. Depending on your CMS those products are linked to the main product page, where the variations options are only available with purchase, or cart related events.

“Main” is a product attribute that has only 2 values: true or false. In order to display only those with main true, you just enter a valid JSON object, as below.

{"main": [true]}

 Filter products by brand

If you want to filter only from specific brand, the same concepts apply.

  • make sure you have items from the brand you want to filter after
  • add brand as filter in the advanced section of Include&Exclude filters

For example the following will include only products that are not “main” (main = false) and brand = “Berner”.

{
  "main": false,
  "brand": "Berner"
}
Was this article helpful?
Dislike 0
Views: 18