Need help buying now? +48-22-219-5163 +1-917-720-3250
My Cart

Your Cart is Empty

Need help buying now?
+48-22-219-5163 +1-917-720-3250

How to disable 'Compare' block in Magento

How to disable 'Compare' block in Magento

Many online stores use specific extensions, add-ons or modified themes to allow customers compare products. But sometimes, a Magento store owner may need to remove a ‘Compare’ block from their site.

Why ‘Compare’ block is needed

‘Compare’ block is a very useful thing as it allows your clients consider all pros and cons of buying this or that product and choose the best variant from the ones they viewed. Of course, you could simply use a theme without such add-on or disable it. But many marketing specialists recommend using that feature on your site to increase sales.

In the standard theme that block is located in catalog.xml, namely in ‘default’ descriptor. The following part of code is responsible for output of that block:

<reference name="right">
	<block
        type="catalog/product_compare_sidebar"
    	before="cart_sidebar"
        name="catalog.compare.sidebar"
        template="catalog/product/compare/sidebar.phtml"
	/>
</reference>

 

This is where you can configure the place in which your ‘Compare’ block will be shown. But what if you do not need to display it at all?

How to remove ‘Compare’ block in Magento

The main problem here is that ‘Compare’ block cannot be disabled through the admin panel. In order to remove this option you need to slightly modify the code. If you are not sure in your programming skills you may use the service of Magento development company.

First of all, you need to disable cache on the site. Then go to app/design/frontend/yourpackage/yourtheme/layout, locate the file reports.xml and open it in the editor. Using ctrl + F locate the following line:

<block type="reports/product_compared" before="right.permanent.callout" 
name="right.reports.product.compared" template="reports/product_compared.phtml" />

 

This line should be commented out using <!-- and --> symbols.

Now, go to your theme folder app/design/frontend/yourpackage/yourtheme/template/reports and locate the file home_product_viewed.phtml. Open it in the editor and find the following lines:

<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
 	<li><span class="separator">|</span> <a href="
  <?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a></li>
<?php endif; ?>

 

They must be commented out as shown above or removed. Then save the changes.

After that go to app/design/frontend/yourpackage/yourtheme/template/checkout/cart and find the file crosssell.phtml. It also contains the code that should be deleted or commented out:

<?php if($_compareUrl=$this->getAddToCompareUrl($_item)): ?>
  	<li><span class="separator">|</span> <a href="
    <?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a></li>
<?php endif; ?>

 

Save the changes again and repeat the same actions in folder app/design/frontend/yourpackage/yourtheme/template/catalog/product/view, file addto.phtml, delete or comment out the lines:

<?php if($_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product) ): ?>
	<li><span class="separator">|</span> <a href="
  <?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a></li>
<?php endif; ?>

 

After that move to app/design/frontend/yourpackage/yourtheme/template/catalog/product, open file new.phtml and locate the lines:

<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
  	<li><span class="separator">|</span> <a href="
    <?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a></li>
<?php endif; ?>

 

Remove or disable them.

The last step is to go to app/design/frontend/yourpackage/yourtheme/template/catalog/product, locate the file list.phtml, then remove or disable the following code:

<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
  	<li><span class="separator">|</span> <a href="
    <?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a></li>
<?php endif; ?>

 

This code should be removed in two places, or the system may attempt to compare the products because of the file template/catalog/product/list.phtml.

Save all changes after the modifications are complete. These actions do not only stop the functionality of the block ‘Compare’ but also help to avoid the attempts of displaying products from separate system files.

Now, do not forget to enable cache and check the changes you have made. Please share this article to your friends and write your comments about your ways of disabling ‘Compare’ block in Magento.

Newsletter