Remove “Add to Compare” Text on Product Listing in Magento
on February 24, 2012
Step 1
To remove the Add to Compare link, you just need to edit the .phtml file that inserts the link into the product view. By commenting out the block of code that inserts the link, you can easily remove it from the product listing. Download a copy of YOUR_PACKAGE/YOUR_TEMPLATE/catalog/product/view/addto.phtml
via FTP. Open the file in a text editor and find the following code:
<?php if($_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product) ): ?> <a href="<?php echo $_compareUrl ?>"><?php echo $this->__('add to compare') ?></a> <?php endif; ?>
Step 2
Comment out the code that adds the link (see lines 1 and 5 below):
<!-- <?php if($_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product) ): ?> <a href="<?php echo $_compareUrl ?>"><?php echo $this->__('add to compare') ?></a> <?php endif; ?> -->
And that’s it! Upload the modified addto.phtml file and check the product listing — the “Add to Compare” link will be gone. If it is not, flush Magento’s cache and refresh the page.
Note: this was tested on a Magento 1.4.2 install; however, it should work for Magento 1.3 through 1.6, although the code may be on a different line.
it’s about time that someone posted a simple way of getting rid of the Compare feature. Nice job! I use Magento 1.6.1.
one other place to get rid of the Compare on your List / Grid Views is in the YOUR_PACKAGE/YOUR_TEMPLATE/catalog/product/list.phtml
Rem out the
helper(‘wishlist’)->isAllow()) : ?>
<a href="helper(‘wishlist’)->getAddUrl($_product) ?>” class=”link-wishlist”>__(‘Add to Wishlist’) ?>
getAddToCompareUrl($_product)): ?>
| <a href="” class=”link-compare”>__(‘Add to Compare’) ?>
You can disable the Compare products functionality in Magento by following these steps:
Edit app/code/core/Mage/Catalog/Helper/Product/Compare.php and change the following code:
public function getAddUrl($product)
{
return $this->_getUrl(’catalog/product_compare/add’, $this->_getUrlParams($product));
}
to
public function getAddUrl($product)
{
//return $this->_getUrl(’catalog/product_compare/add’, $this->_getUrlParams($product)); return false;
}
Edit ./app/design/frontend/base/default/layout/catalog.xml (if you are using a different Magento theme, enter its name instead of default) and change the following code:
to
<!– –>
Great tutorial…. it is still up to date and worked well.
You saved my day 🙂
Hi,
I deleted addto.phtml file. Now ADD TO WISHLIST AND ADD TO COMPARE is not displaying,
is any problem for deleting entire addto.phtml file insted of only somelines.?
Yes, you should only delete the code indicated in the instructions above.