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:
SELECT * FROM eav_attribute where attribute_code = 'is_anchor'
Now, run the below query to update all the category to Anchor YES:
UPDATE catalog_category_entity_int set value = 1 where attribute_id = 54;
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