I have my comparable products page in a table.
In my fist row there is Description.
In my 3rd row there is SKU
I want to move my SKU in the first row

How to achieve it?


The attributes that are displayed in the compare list are retrieved in the method Mage_Catalog_Model_Resource_Product_Compare_Item_Collection::getComparableAttributes but this method does not sort the attributes in any way.
So they are retrieved in the way that mysql wants it. Which is not very predictable.
You can take the result of that method and try to parse the result and rearrange the attributes as you want, or you can override the method and after the line ->where('main_table.attribute_id IN(?)', $attributeIds) add this

->order(new Zend_Db_Expr('CASE WHEN main_table.attribute_code = "sku" THEN 1 ELSE 0 END DESC'));
  • but i cant find the line" ->where('main_table.attribute_id IN(?)', $attributeIds)" in list.phtml – Ranganathan May 3 '17 at 7:21
  • it's not in list.phtml. It's in Mage_Catalog_Model_Resource_Product_Compare_Item_Collection – Marius May 3 '17 at 7:21
  • is there any way to edit compared product page without touching mage files? – Ranganathan May 3 '17 at 7:23
  • yes...rewrite the class properly. There are a lot of docs on how to rewrite a resource model. – Marius May 3 '17 at 7:23
  • Is there any link to study about that? pls help me – Ranganathan May 3 '17 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.