File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
Catalog/Model/Resource/Product/Compare/Item Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -215,15 +215,23 @@ public function getComparableAttributes()
215
215
$ eavConfig = Mage::getSingleton ('eav/config ' );
216
216
$ attributeIds = $ eavConfig ->getAttributeSetAttributeIds ($ setIds );
217
217
$ this ->_comparableAttributes = [];
218
+ $ attributeSortInfo = [];
218
219
foreach ($ attributeIds as $ attributeId ) {
219
220
$ attribute = $ eavConfig ->getAttribute (Mage_Catalog_Model_Product::ENTITY , $ attributeId );
220
221
if ($ attribute ->getData ('is_comparable ' )) {
221
222
$ this ->_comparableAttributes [$ attribute ->getAttributeCode ()] = $ attribute ;
223
+ $ attributeSortInfo [$ attribute ->getAttributeCode ()] = $ eavConfig ->getAttributeSetGroupInfo ($ attributeId , $ setIds );
222
224
}
223
225
}
224
226
225
- usort ($ this ->_comparableAttributes , function ($ a , $ b ) {
226
- return $ a ->getPosition () - $ b ->getPosition ();
227
+ uasort ($ this ->_comparableAttributes , function ($ a , $ b ) use ($ attributeSortInfo ) {
228
+ /** @var Mage_Eav_Model_Entity_Attribute_Abstract $a */
229
+ /** @var Mage_Eav_Model_Entity_Attribute_Abstract $b */
230
+
231
+ $ aSort = $ attributeSortInfo [$ a ->getAttributeCode ()]; // contains group_id, group_sort, sort
232
+ $ bSort = $ attributeSortInfo [$ b ->getAttributeCode ()]; // contains group_id, group_sort, sort
233
+
234
+ return $ aSort ['group_sort ' ] <=> $ bSort ['group_sort ' ] ?: $ aSort ['sort ' ] <=> $ bSort ['sort ' ];
227
235
});
228
236
}
229
237
}
Original file line number Diff line number Diff line change @@ -598,6 +598,27 @@ public function getAttributeSetAttributeIds($attributeSetId)
598
598
return array_keys ($ attributes );
599
599
}
600
600
601
+ /**
602
+ * Return first attribute sorting information found for a given list of attribute sets
603
+ * @param int $attributeId
604
+ * @param int|int[] $attributeSetIds
605
+ * @return false|array
606
+ */
607
+ public function getAttributeSetGroupInfo ($ attributeId , $ attributeSetIds )
608
+ {
609
+ if (!is_array ($ attributeSetIds )) {
610
+ $ attributeSetIds = [$ attributeSetIds ];
611
+ }
612
+
613
+ foreach ($ attributeSetIds as $ attributeSetId ) {
614
+ if (isset ($ this ->_attributeSetInfo [$ attributeId ][$ attributeSetId ])) {
615
+ return $ this ->_attributeSetInfo [$ attributeId ][$ attributeSetId ];
616
+ }
617
+ }
618
+
619
+ return false ;
620
+ }
621
+
601
622
/**
602
623
* @param mixed $entityType
603
624
* @param string $attribute
You can’t perform that action at this time.
0 commit comments