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:
- Login to Admin panel
- Navigate to Catalog > Categories
- Select the Category
- Expand the Display Settings
- Enable the 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:
1 |
SELECT * FROM eav_attribute where attribute_code = 'is_anchor' |
Now, run the below query to update all the category to Anchor YES:
1 |
UPDATE catalog_category_entity_int set value = 1 where attribute_id = 54; |
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.
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
2 Comments
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.