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.
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.
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.
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:
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.
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.
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.
After applying the above method, layered navigation includes only those filters for which matching products can be found as mentioned in the below image:
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.
Quite easy, right?
If you find any doubt regarding this method, feel free to mention in the Comments section below.
It would be a pleasure to help you.
If you still want to improve the navigation further, you can sort Magento 2 layered navigation attributes programmatically.
Do not forget to share the solution with Magento Community via social media.
Get Weekly Updates
Never miss Magento tips, tricks, tutorials, and news.
Thank you for subscribing.
Something went wrong.