0

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.

Magento\Catalog\Model\Layer\Filter\Attribute

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? – Ankita Patel Nov 14 at 7:09
  • Without add options from admin or data base. – Ankita Patel Nov 14 at 7:10
0

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/*

Your Answer

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

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