How to Remove Filterable Attribute Values with 0 Products from Magento 2 Layered Navigation

How to Remove Filterable Attribute Values with 0 Products from Magento 2 Layered Navigation

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:

How to Remove Filterable Attribute Values with 0 Products from Magento 2 Layered Navigation

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

  1. Login to the admin panel.
  2. Navigate to Stores > Attributes > Product.
  3. Select and open the attribute.
  4. Click on Storefront Properties under Attribute Information section.How to Remove Filterable Attribute Values with 0 Products from Magento 2 Layered Navigation
  5. Select Filterable (with results) from the Use in Layered Navigation dropdown.
  6. 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:

How to Remove Filterable Attribute Values with 0 Products from Magento 2 Layered Navigation

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.

Thank You.

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

0
(based on 0 Reviews)

An expert in his field, Jignesh is the team leader at Meetanshi. His passion for Magento has inspired others in the team too. Apart from work, he is a cricket lover.

Leave a reply:

Your email address will not be published.