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 MagentoCatalogModelLayerCategoryFilterableAttributeList 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).
<virtualType name="categoryFilterList" type="[Vendor Name][Module Name]ModelLayerFilterList">
<arguments>
<argument name="filterableAttributes" xsi:type="object">MagentoCatalogModelLayerCategoryFilterableAttributeList</argument>
</arguments>
</virtualType>
After override FilterList, put below code in that file for change the Filter Position:
<?php
namespace [Vendor Name][Module Name]ModelLayer;
/**
* Override FilterList Class
*/
class FilterList extends MagentoCatalogModelLayerFilterList {
protected $_categoryFactory;
public function __construct(MagentoCatalogModelCategoryFactory $categoryFactory, MagentoFrameworkViewElementTemplateContext $context, MagentoFrameworkRegistry $registry) {
$this->_registry = $registry;
$this->_categoryFactory = $categoryFactory;
parent::__construct($context);
}
public function getFilters(MagentoCatalogModelLayer $layer) {
$arr = array();
$new = array();
$value = array();
if (!count($this->filters)) {
$this->filters = [$this->objectManager->create($this->filterTypes[self::CATEGORY_FILTER], ['layer' => $layer]), ];
$i = 1;
$arraycheck = array();
$inarraycheck = array();
$valuesCol = array();
$allready = array();
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$currentcategory = $this->_registry->registry('current_category');
$categoryId = $currentcategory->getId();
$categoryData = $this->_categoryFactory->create()->load($categoryId);
$getData = $categoryData->getData();
foreach ($getData as $key => $value) {
$new[] = $key;
}
foreach ($this->filterableAttributes->getList() as $attribute) {
$code = $attribute->getAttributeCode();
if (in_array($code, $new)) {
if (!empty($getData[$code])) {
$valuesCol[] = $posVal = $getData[$code];
}
}
}
foreach ($this->filterableAttributes->getList() as $attribute) {
$code = $attribute->getAttributeCode();
if (in_array($code, $new)) {
if (!empty($getData[$code])) {
$posVal = $getData[$code];
array_push($inarraycheck, $attribute->getAttributeCode());
if (array_key_exists($posVal, $this->filters)) {
$arraycheck[] = $this->createAttributeFilter($attribute, $layer);
$this->filters[$posVal] = $this->createAttributeFilter($attribute, $layer);
} else {
$this->filters[$posVal] = $this->createAttributeFilter($attribute, $layer);
}
} else {
$this->filters[$i] = $this->createAttributeFilter($attribute, $layer);
}
} else {
if (in_array($i, $valuesCol)) {
$allready[] = $this->createAttributeFilter($attribute, $layer);
} else {
$this->filters[$i] = $this->createAttributeFilter($attribute, $layer);
}
}
$i++;
if (!empty($arraycheck)) {
foreach ($arraycheck as $key => $value) {
if (!in_array($attribute->getAttributeCode(), $inarraycheck)) {
$this->filters[$i] = $value;
}
$i++;
$arraycheck = array();
}
}
if (!empty($allready)) {
foreach ($allready as $key1 => $value1) {
$this->filters[$i] = $value1;
}
$i++;
$allready = array();
}
}
ksort($this->filters);
}
return $this->filters;
}
}
?>
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.
php bin/magento setup:di:compile php bin/magento cache:flush
