Catalog filter API (Facets) exhibits unexpected behavior when fields of different specifications have the same name
ID:
Backlog
Published on 8/16/2017
•
Last update on 12/22/2022
Summary
When executing the filter API (Facet), an error 500 message ("An item with the same key has already been added") is displayed if the result contains specification fields (of product or SKU) with the same name.
API EndPoint: /api/catalog_system/pub/facets/search/{category}?map=c
Simulation
To simulate this scenario:
- Create a field named "size" for example in any subcategory of the category you wish to test. Define it as a filter.
- Create a field having the same name ("size", in our example) in another subcategory of the category you wish to test. Define it as a filter as well.
- Input values in these fields;
- Create a product in each subcategory and fill out the defined field ("size" in our example)
- Wait for the product indexation to finish (about 5 minutes)
- Execute the endpoint /api/catalog_system/pub/facets/search/{category}?map=c
Workaround
To prevent this behavior, avoid creating fields having the same name in parallel categories (subcategories of the same parent category).
If the API is used for rendering a side menu (filter), it can replaced by the native searchNavigator control. Click here to find out more