Product Compare Option: How To Disable

In one of the previous articles of our blog we discussed how to add products for comparison. Now we will review how to disable that option if it is not needed.

First of all, open the list.phtml file in app/design/frontend/default/themeXXX/template/catalog/product folder on your server. You can do that with the help of an FTP client.

Then, remove the ‘add to compare’function from the product listing page. Using CTRL+F hotkeys locate and remove the following code:

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


If you plan to disable the option temporarily you may not remove the code but comment it out with a double slash for PHP: //. For HTML code use symbols <!— comment —>. Then repeat these steps to remove the option in the product's grade.

In order to disable ‘Add To Compare’ option on the product page, copy the addto.phtml file which is located in app/design/frontend/base/default/template/catalog/product/view folder into app/design/frontend/default/themeXXX/template/catalog/product/view folder, then remove or comment out the following code:

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


If you wish to remove the compare option from the sidebar you need to edit the catalog.xml file in app/design/frontend/default/themeXXX/layout folder, then remove or comment out the following code:

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


As soon as the changes are saved upload modified files on the server. If the changes are not applied on the site, you should clean cache in Magento ® and your browser cache. If you have any questions please feel free to leave comments on this article or email GoMage team directly.

Contact us
Fill in the data using social media accounts
Thank you!
We will contact you shortly

Set up your store for growth during the economic crisis

Popular Posts

Join 5,246 Magento-obsessed readers in our mailing list