Filtering Results by Custom Attribute

Filter Autocomplete, Search and Category results up front by a custom attribute, such as B2B or B2C.

Last updated

On this page

Overview

Filtering results by user attributes has broad applications in e-commerce. It filters searches through the Autocomplete, Search and Category APIs immediately, rather than after the user interacts with the site.

For instance, consider an e-store for both B2B and B2C customers, where certain products are exclusive to B2C. Each product then needs a custom field that indicates the business type (B2B, B2C or both). This custom field can be of string, boolean or integer data type.

Set up the attribute

  1. Add the field to the Product Feed.
  2. On the Athena Dashboard, go to Settings -> Landing Page and define the custom attribute under the Custom Attributes section.
  3. Reindex your data.

Send the filter

After the reindex succeeds, you can filter data. Requests to all the API calls should follow the format below.

Search API request

JSON
{
   "q": "Yoga",
   "token": "{{ website_token }}",
   "custom_field_filters": {
        "bussines_type": "b2c"
   }
}

Category API request

JSON
{
   "category": "14",
   "level": "2",
   "token": "{{ token }}",
   "custom_field_filters": {
        "bussines_type": "b2b"
   }
}