check the modifications in function below: Function is in file vendor/magento/module-catalog/Model/ResourceModel/Product/Compare/Item/Collection.php
public function getComparableAttributes()
{
if ($this->_comparableAttributes === null) { $this->_comparableAttributes = []; $setIds = $this->_getAttributeSetIds();
if ($setIds) { $attributeIds = $this->_getAttributeIdsBySetIds($setIds); $select = $this->getConnection()->select()->from(
['main_table' => $this->getTable('eav_attribute')]
)->join(
['additional_table' => $this->getTable('catalog_eav_attribute')],
'additional_table.attribute_id=main_table.attribute_id'
)->joinLeft(
['al' => $this->getTable('eav_attribute_label')],
'al.attribute_id = main_table.attribute_id AND al.store_id = ' . (int)$this->getStoreId(),
[
'store_label' => $this->getConnection()->getCheckSql(
'al.value IS NULL',
'main_table.frontend_label',
'al.value'
)
]
)
->joinLeft(
['as' => $this->getTable('eav_entity_attribute')],
'as.attribute_id = main_table.attribute_id'
)
->where(
'additional_table.is_comparable=?',
1
)->where(
'main_table.attribute_id IN(?)', $attributeIds
)
->order('as.sort_order') //sort by sort_order
; $attributesData = $this->getConnection()->fetchAll($select);
if ($attributesData) { $entityType = \Magento\Catalog\Model\Product::ENTITY; $this->_eavConfig->importAttributesData($entityType, $attributesData);
foreach ($attributesData as $data) { $attribute = $this->_eavConfig->getAttribute($entityType, $data['attribute_code']); $this->_comparableAttributes[$attribute->getAttributeCode()] = $attribute;
} unset($attributesData);
}
}
}
return $this->_comparableAttributes;
}
Code language: PHP (php)