1

how to show all attributes even filters applied i.e., if we click on like color options then some options get's cleared so i want to display all filters whether if we choose another option also.

2 Answers 2

0

You can show color attribute even if there is no products available related to this. You have to select Filterable (no results) in attribute's storefront properties.

Navigate to

Stores > Attributes > Product > Color > Storefront Properties > Used in layered navigation

and select Filterable (no results).

1
  • Hi @dinesh, yes it is working but there are all options which have no results also so I want with results. Nov 20, 2017 at 8:16
0

To show all attributes even filters applied in magento 2.Please check below solution.

  1. Have to set Filterable (No results) For that Attribute:

Store > Attribute > Product > {Your Attribute} >StoreFront Properties > Used in layered Navigation

select Filterable (no results).

  1. Checked Category Selected as Anchor.
  2. Coding changes to display all attribute.

    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 }

  3. Do 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/*

Thank you

Your Answer

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

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