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
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).
-
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
To show all attributes even filters applied in magento 2.Please check below solution.
- Have to set Filterable (No results) For that Attribute:
Store > Attribute > Product > {Your Attribute} >StoreFront Properties > Used in layered Navigation
select Filterable (no results).
- Checked Category Selected as Anchor.
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 thisif($productCollection->getValueSearchRequestName() != "catalog_view_container"){ $this->setItems([]); // set items to disable show filtering }
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