开发者

Compare Products Sidebar Item Doesn't Show Products

When I click "Add to Compare" on a product, a message stating that "such-and-such product successfully added to compare list" appears, however the compare products sidebar shows "You have no items to compare." If I do a print_r($this->helper('catalog/product_compare')->getItemCount()) in template/catalog/product/compare/sidebar.phtml, "0" is returned.

Why won't the sidebar show the products to compare?

Info: Magento version 1.4.0.1 Sessions appear to work for I can add products to the cart and they will 开发者_如何学JAVAstay in the cart as I navigate around the site.

Thank you, Ben


Found the solution after several hours of searching: One or more of the indexes needed to be rebuilt.

In case anyone else encounters this issue, the option to trigger index rebuilding is found in the admin interface by going to the System menu and selecting Index Management.


I've made the changes on this file:

app\code\core\Mage\Catalog\Helper\Product\Compare.php

from line 215. I've commented the if statement out.

/*
if (!$this->_getSession()->hasCatalogCompareItemsCount()) {
    $count = 0;
} else {
*/

and on line 235. Commented the closing bracket out:

/*}*/

It worked for me.

I think thats the solution.


The other reason that compare tools may be broken are some site optimizations like disabling certain events like

controller_action_predispatch controller_action_postdispatch

Check etc/local.xml

<frontend>
    <events>
        <controller_action_predispatch>
            <observers><log><type>disabled</type></log></observers>
        </controller_action_predispatch>
        <controller_action_postdispatch>
            <observers><log><type>disabled</type></log></observers>
        </controller_action_postdispatch>
    </events>
</frontend>

and remove

        <controller_action_predispatch>
            <observers><log><type>disabled</type></log></observers>
        </controller_action_predispatch>
        <controller_action_postdispatch>
            <observers><log><type>disabled</type></log></observers>
        </controller_action_postdispatch>


app\code\core\Mage\Catalog\Helper\Product\Compare.php at line 257

comment if statement doesn't work on magento community v 1.7.0.2

/**
 * Retrieve count of items in compare list
 *
 * @return int
 */
public function getItemCount()
{

   if (!$this->_getSession()->hasCatalogCompareItemsCount()) {
        $this->calculate();
    }


    return $this->_getSession()->getCatalogCompareItemsCount();
}


I have the same problem and it was because of my browser (chrome), I switch to firefox and the 'Add to Compare' option work fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜