/** * Compare attributes sorting * * @param \Magento\Catalog\Model\Entity\Attribute $attributeOne * @param \Magento\Catalog\Model\Entity\Attribute $attributeTwo * @return int */ public function attributesCompare($attributeOne, $attributeTwo) { $sortOne = $attributeOne->getGroupSortPath() * 1000 + $attributeOne->getSortPath() * 0.0001; $sortTwo = $attributeTwo->getGroupSortPath() * 1000 + $attributeTwo->getSortPath() * 0.0001; if ($sortOne > $sortTwo) { return 1; } elseif ($sortOne < $sortTwo) { return -1; } return 0; }