0

I am trying to replace the helper that provides the compare box with the list of products added to it. My helper is going to get the product ids from a cookie instead of from Magentos session.

My own class in app/code/local/Mynamespace/Mymodule/Helper/Data.php extends Mage_Core_Helper_Abstract.

When looking at list.phtml and sidebar.phtml in app/design/frontend/base/default/template/catalog/product/compare/ they seem to be calling different methods when getting the compare products collection. sidebar.phtml seems to be calling Mage_Catalog_Block_Product_Compare_Sidebar->helper('catalog/product_compare')->getItemCollection() and list.phtml seems to be calling Mage_Catalog_Block_Product_Compare_List->getItems().

What method(s) do I need to be replacing and in what classes are they present?

1

As there is code duplication between the two core methods for retrieving/building the compare collection (refs here and here), I would suggest that you do the following:

  1. Rewrite Mage_Catalog_Helper_Product_Compare, overriding its getItemCollection() method
  2. Rewrite the Mage_Catalog_Block_Product_Compare_List and block's getItems() method to simply return the product compare helper's overridden getItemsCollection() method.

Rewrite XPATHs are global/helpers/catalog/rewrite/product_compare and global/blocks/catalog/rewrite/compare_list respectively.

0

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.