free
web stats

Fill the form & Get Installation Support

We don't monkey around your business.

GET IN TOUCH WITH US NOW





captcha

How to set layered navigation filters position category wise in Magento 2?

By default, Magento adjusts the attribute position when we create product attributes. But, systematically, the same position will get apply for all categories.

So if we wanted to display attributes position differently for categories wise, then this article is your solution.

First, you have to create text type Category Attributes
which you need to set differently category wise (Please verify product attribute code and category attribute code).

In the text type attributes, you have to set the require position value as shown in below screenshot.

After creating all the category attributes and setting value in all categories, you have to move forword in the next step:

Override the Magento\Catalog\Model\Layer\Category\FilterableAttributeList file.

For that, you need to use virtualType in di.xml in your module (You can create a new module or use any existing module. Create only di.xml in that module).

After override FilterList, put below code in that file for change the Filter Position:

After doing all the steps run below commands and check output on front end.

You will see layered navigation filters are displayed differently in each category.