0

I see when there is no item selected to compare, the block-compare is not displaying in sidebar and after adding product to compare it is there. How to display this block always and show message"You have not selected any items to compare" for example?

3 Answers 3

1

Natively the block should show regardless, and if there's no item, it would say "You have no items to compare.". So it looks like your theme is customised, or a module overwrites it. Make sure your catalog/product/compare/sidebar.phtml in your theme folder is similar to the default one.

1
  • Even I copied the sidebar.phtml from default to my theme folder, still I can not see the block :(
    – Zinat
    Commented Oct 20, 2015 at 14:24
0

The core code will not display the block if there's no recently compared products:

protected function _toHtml()
{
    if (!$this->getCount()) {
        return '';
    }

    $this->setRecentlyComparedProducts($this->getItemsCollection());

    return parent::_toHtml();
}

To change this behavior you can do a rewrite of the Mage_Reports_Block_Product_Compared block to fulfill your needs.

1
  • This is for the "Recently Compared Products" block, that doesn't apply here Commented Oct 20, 2015 at 14:44
0

I figured it out. In default sidebar.phtml there is a line $_items = $_helper->getItemCount() > 0 ? $_helper->getItemCollection() : null; I removed the condition of checking $_items and it works now.

1
  • Can you paste the content of your sidebar.phtml, your solution isn't really one. Commented Oct 20, 2015 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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