2014-08-14

How to add compare link to top links

First of all you have to create helper in your own module with two methods:
/**
 * Return label for comparing products list
 *
 * @return int
 */
public function getCompareLabel()
{
    $count = Mage::helper('catalog/product_compare')->getItemCollection()->getSize();
    return $this->__('Compare (%s)', $count);
}

/**
 * Return whether visible compare link
 *
 * @return bool
 */
public function getCompareLinkIsVisibleClass()
{
    $count = Mage::helper('catalog/product_compare')->getItemCollection()->getSize();

    if ($count > 0) {
        return '';
    }

    return 'class="no-display"';
}
Then add to layout xml (in block where you want to add link):

 
Where helper="slirx_ajaxpanel - your helper, module="slirx_ajaxpanel" - your module.

And in app.js (for rwd theme, for another you have to add this code to any js file that will be loaded on pages with your compare link)
$j('body').delegate('#header-account .compare', 'click', function(event) {
 var _url = $j(this).attr('href');
 popWin(_url, 'compare', 'top:0,left:0,width=820,height=600,resizable=yes,scrollbars=yes');

 event.preventDefault();
});

No comments:

Post a Comment