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
- Add the field to the Product Feed.
- On the Athena Dashboard, go to Settings -> Landing Page and define the custom attribute under the Custom Attributes section.
- 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
{
"q": "Yoga",
"token": "{{ website_token }}",
"custom_field_filters": {
"bussines_type": "b2c"
}
}
Category API request
{
"category": "14",
"level": "2",
"token": "{{ token }}",
"custom_field_filters": {
"bussines_type": "b2b"
}
}