I have override vendor/magento/module-catalog/Model/Layer.php for custom product collection but now the layer navigation and product count is working wrong, I checked for Magento\CatalogSearch\Model\Search\IndexBuilder.php file but this is not exist in M 2.4.1 + elastic search. I am following this link https://www.rakeshjesadiya.com/apply-custom-conditions-for-product-collection-in-magento-2/ and https://community.magento.com/t5/Magento-2-x-Programming/Incorrect-product-count-in-layered-navigation-after-overriding/m-p/104534#M5628

But not working for me.

1 Answer 1


I searched a lot on this and found below link which helped to resolve the issue for me.

Custom product collection filter doesnt work with Magento 2 elasticsearch ( but work with mysql)

  • Hello @Yogita, Please update the Helper file code in this case,
    – Manjunath
    Commented Dec 28, 2021 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.