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 areLogin to Admin panel
1. Navigate to Catalog > Categories
2. Navigate to Catalog > Categories
3. Select the Category
4. Expand the Display Settings
5. 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;
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.
Thank You.