Set up your attributes order in "Attributes set" as you wish to be listed in frontend (product page and compare window). In product page attributes are listed in correct order (Additional information section). Now add this product to compare list. Compare it.
Attributes order should be the same like you set it up in "Attribute set" and same like in Additional information. In compare window attributes are in a different order. This need a fix since is a bug. Maybe a global position that can be changed for an attribute could solve elegant this issue. There is a position field but for Layering Navigation only.
Solved! Go to Solution.
Hi,
This is how I solved the problem. Override this file
app\code\core\Mage\Catalog\Model\Resource\Product\Compare\Item\Collection.php
as
app\code\local\Mage\Catalog\Model\Resource\Product\Compare\Item\Collection.php
Around line 220, find "public function getComparableAttributes()"
Comment the original function and replace it with the following code
/** Function overridden by nadshez to fix sort order in comparison list */ public function getComparableAttributes() { if (is_null($this->_comparableAttributes)) { $this->_comparableAttributes = array(); $setIds = $this->_getAttributeSetIds(); if ($setIds) { $select = $this->getConnection()->select() ->from(array('main_table' => $this->getTable('eav/attribute'))) ->join( array('additional_table' => $this->getTable('catalog/eav_attribute')), 'additional_table.attribute_id=main_table.attribute_id' ) ->joinLeft( array('al' => $this->getTable('eav/attribute_label')), 'al.attribute_id = main_table.attribute_id AND al.store_id = ' . (int) $this->getStoreId(), array('store_label' => new Zend_Db_Expr('IFNULL(al.value, main_table.frontend_label)')) ) ->joinLeft( array('ai' => $this->getTable('eav/entity_attribute')), 'ai.attribute_id = main_table.attribute_id' ) ->where('additional_table.is_comparable=?', 1) ->where('ai.attribute_set_id IN(?)', $setIds) ->order(array('ai.attribute_group_id ASC', 'ai.sort_order ASC')); $attributesData = $this->getConnection()->fetchAll($select); if ($attributesData) { $entityType = 'catalog_product'; Mage::getSingleton('eav/config') ->importAttributesData($entityType, $attributesData); foreach ($attributesData as $data) { $attribute = Mage::getSingleton('eav/config') ->getAttribute($entityType, $data['attribute_code']); $this->_comparableAttributes[$attribute->getAttributeCode()] = $attribute; } unset($attributesData); } } } return $this->_comparableAttributes; }
That's it. Hope this helps. Thanks.
Hi @ADDISON,
Please have look at this post, I think you will be able to find the solution for the sort order on the compare (of attributes).
http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_24491200.html
Maybe this module, alså could help you:
http://shop.etwebsolutions.com/eng/et-advancedcompare.html
The module is free, and you could use parts of it, to fit you needs:
https://bitbucket.org/etws/et_advancedcompare
Hi,
This is how I solved the problem. Override this file
app\code\core\Mage\Catalog\Model\Resource\Product\Compare\Item\Collection.php
as
app\code\local\Mage\Catalog\Model\Resource\Product\Compare\Item\Collection.php
Around line 220, find "public function getComparableAttributes()"
Comment the original function and replace it with the following code
/** Function overridden by nadshez to fix sort order in comparison list */ public function getComparableAttributes() { if (is_null($this->_comparableAttributes)) { $this->_comparableAttributes = array(); $setIds = $this->_getAttributeSetIds(); if ($setIds) { $select = $this->getConnection()->select() ->from(array('main_table' => $this->getTable('eav/attribute'))) ->join( array('additional_table' => $this->getTable('catalog/eav_attribute')), 'additional_table.attribute_id=main_table.attribute_id' ) ->joinLeft( array('al' => $this->getTable('eav/attribute_label')), 'al.attribute_id = main_table.attribute_id AND al.store_id = ' . (int) $this->getStoreId(), array('store_label' => new Zend_Db_Expr('IFNULL(al.value, main_table.frontend_label)')) ) ->joinLeft( array('ai' => $this->getTable('eav/entity_attribute')), 'ai.attribute_id = main_table.attribute_id' ) ->where('additional_table.is_comparable=?', 1) ->where('ai.attribute_set_id IN(?)', $setIds) ->order(array('ai.attribute_group_id ASC', 'ai.sort_order ASC')); $attributesData = $this->getConnection()->fetchAll($select); if ($attributesData) { $entityType = 'catalog_product'; Mage::getSingleton('eav/config') ->importAttributesData($entityType, $attributesData); foreach ($attributesData as $data) { $attribute = Mage::getSingleton('eav/config') ->getAttribute($entityType, $data['attribute_code']); $this->_comparableAttributes[$attribute->getAttributeCode()] = $attribute; } unset($attributesData); } } } return $this->_comparableAttributes; }
That's it. Hope this helps. Thanks.
@nadshez Sorry for my late reply. Thank you for your solution. I tried ET Advanced Compare before but it is using AJAX and creates trouble with Varnish. Yours works great, so far so good. I posted a bug ticket into Magento list for fixing this in next releases. It is a bad programming logical to get in product page a sorting order then in comparison windows other sorting order.
From ET Advanced Compare I will take the idea of creating an attribute to disable adding a product into comparison list. It is just an if statement in products list and product view page.