Quite easy, right?
Thank you for subscribing.
If you find any doubt regarding this method, feel free to mention in the Comments section below.
Layered Navigation in Magento 2 allows users to narrow their search with filters for category, price, brand, or any other available attributes to find the desired product. It improves the on-site experience and speeds up the conversion process.
Any attribute value that already applies to all products shown in the list should still appear as an available filter. Attribute values with a count of zero (0) product matches are omitted from the list of available filters.
Layered navigation includes filters for all available attribute values and their product counts, including those with zero (0) product matches as shown in below image:
Method to remove filterable attribute values with 0 products from Magento 2 layered navigation
- Login to the admin panel.
- Navigate to Stores > Attributes > Product.
- Select and open the attribute.
- Click on Storefront Properties under Attribute Information section.
- Select Filterable (with results) from the Use in Layered Navigation dropdown.
- Click on Save Attribute button.
Something went wrong.
It would be a pleasure to help you.
That looks bulky and becomes complicated for customers to choose a preferable product if large amounts of categories and products are there. Also, it is unnecessary to display attribute values with 0 products on the frontend.
In default Magento 2, the layered navigation appears in the left column of the category page, search result pages and sometimes on the store’s home page.
After applying the above method, layered navigation includes only those filters for which matching products can be found as mentioned in the below image:
If you still want to improve the navigation further, you can sort Magento 2 layered navigation attributes programmatically.
Never miss Magento tips, tricks, tutorials, and news.
Get Weekly Updates
Hence, I have come up with the below solution to remove filterable attribute values with 0 products from Magento 2 layered navigation and omit the attribute values with a count of zero (0) product matches.
Your online store visitor does not have time to browse all the products and find what they are looking for. This process should be as seamless as walking in a brick and mortar store and asking for an item.
Do not forget to share the solution with Magento Community via social media.