How to Set Anchor to YES in all Categories in Magento 2

How to Set Anchor to YES in all Categories in Magento 2

In Magento 2 stores, by default, all the categories created through the admin is set to “No” for the option “is Anchor”. Setting “Is Anchor” to “Yes” activates the Layered Navigation in Magento 2 which is also known as filtered navigation.

To enable layered navigation, the admin has to follow certain steps for each category which are:

  1. Login to Admin panel
  2. Navigate to Catalog > Categories
  3. Select the Category
  4. Expand the Display Settings
  5. Enable the Anchor to “YES”.

Manually-set-anchor-to-yes

 

There is no method to update this setting in bulk from Magento 2 admin and the task to set Anchor to YES in all Magento 2 categories one by one is tedious and time-consuming when you have a lot of categories.

What if I show the programmatic method to enable the layered navigation for all Magento 2 categories at once?

Set anchor to YES in all categories in Magento 2 with the SQL queries given here. It will save your time and offer layered navigation to the store visitors to help them easily find the products.

 

Method to Set Anchor to YES in all Categories in Magento 2:

Identify the attribute id of the is_anchor attribute:

Now, run the below query to update all the category to Anchor YES:

And done!

With the above SQL commands, enrich the user experience on your store and at the same time reduce admin task by the programmatic method to set anchor to YES in all categories in Magento 2.

Do let me know in the Comments section if you face any issues in the above query implementation. I’d be happy to help

Thank You.

5
(based on 7 Reviews)

Sanjay is a co-founder at Meetanshi. He is a certified Magento developer who loves creating Magento E-commerce solutions. When he is not engrossed with anything related to Magento, he loves to play cricket.

2 comments On How to Set Anchor to YES in all Categories in Magento 2

  • i have static block in Magento 2. I show static block after every category menu . these anchor work fine on desktop but when i click on mobile view its not working please help me or guide better

    • The solution works fine with me. The issue must be with your custom theme. Please try to implement the above solution in the default theme.

Leave a Reply

%d bloggers like this: