I am Creating a functionality to show all attribute of layered navigation in magento2. All options of particular attribute must shown before & after applying filter in layered navigation.

I have debug this class for the same.


enter image description here

Is there any specific method where filter options are added in filter attribute? where i can add all options to filter attribute..?

  • Hello. do you know about how to push option in style attribute? Nov 14, 2019 at 7:09
  • Without add options from admin or data base. Nov 14, 2019 at 7:10
  • do u have ay solution for that same issue facing while implementing multiselect filter?? Jun 14, 2022 at 10:42

1 Answer 1


We have to override Magento\CatalogSearch\Model\Layer\Filter\Attribute File. So Use this link https://magenticians.com/override-model-magento-2/ To override Model in Magento 2.After Override of this model complete do below changes in Attribute.php file of your.

Have to change in apply() Function of Attribute.php file.

Please check $this->setItems([]) in apply() function and replace this line by this

if($productCollection->getValueSearchRequestName() != "catalog_view_container"){
    $this->setItems([]); // set items to disable show filtering

And have to DI compile,Flush cache,Deploy Static content and remove files from generated folder then check it.

php bin/magento setup:di:compile

php bin/magento cache:flush

php bin/magento setup:static-content:deploy -f

rm -rf generated/*

  • Not working for me
    – Unknown
    May 4, 2020 at 10:03
  • there is no getValueSearchRequestName this function
    – hkguile
    Oct 21, 2022 at 7:40

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.