I want to add some conditions for the layer navigation counter. Basically I want to skip from counting some products.

In vendor/magento/module-catalog-search/Model/Layer/Filter/Category.php in _getItemsData we have a products collection, and then based on the collection, all the counter for the categories comes form this line :

 $optionsFacetedData = $productCollection->getFacetedData('category');

On the getFacetedData function we have:

 $aggregations = $this->searchResult->getAggregations();

This will return all the counters for all categories, attributes, prices etc...

If I add some condition on the product collection nothing happen with the counter, even if i remove all the items from the collection i still have the same numbers for category counter.

Does anyone know how this getAggregations function works, and how the counter works?

I mean where in the code i can find the actual assignment for the category x and the number of products associated with the category.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.