Disable “Add to Compare” Feature in Magento 2

  • Posted by Envision Ecommerce
  • /
  • May 14, 2016
Disable-Add-to-Compare-Magento2

“Add to Compare” feature is integrated with Magento 2 (by-default). As we have discussed about disabling of Wishlist functionality in Magento 2 in our last post, “Add to Compare” feature may also be irrelevant to you like “Wishlist” feature.

However, there is no option available in the admin to remove this product comparison functionality like Wish List. Thus, leaving us with the only two options, first is standard, and another one is not so standard.

These ways are pretty straightforward. So with no further delay, let’s start!

According to the first standard way (followed by Magento), you will necessitate overriding the:

module-catalog/view/frontend/templates/product/list.phtml template.

This way is similar to Magento 1 and you would only require to copy the content of the file we named above in a new file within your theme placed under:

<theme_dir>/Magento_Catalog/templates/product/list.phtml.

In that file, comment the below lines at around line number 111 to 121 in Magento 2.0.1:

<?php

$compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare');

?>

<a href="#"

class="action tocompare"

title="<?php echo $block->escapeHtml(__('Add to Compare')); ?>"

aria-label="<?php echo $block->escapeHtml(__('Add to Compare')); ?>"

data-post='<?php / @escapeNotVerified / echo $compareHelper->getPostDataParams($_product); ?>'

role="button">

<span><?php / @escapeNotVerified / echo __('Add to Compare') ?></span>

</a>

2) There is another quick but not so standard way to do so:

Disabling “Add to Compare” feature via a CSS rule, is a quite quick way as compared to the first standard way. You only need to do:

body.catalog-product-view .product-info-main .product-addto-links a.tocompare {

display: none;

}

Very simple & quick, right?

Aforementioned ways aid to disable “Add to Compare” feature in Magento 2 with all essential information required by Magento 2 warriors. If you still don’t get these ways exactly or want to ask about particular issues related to Magento 2 compare product feature, you can feel free to ask here through your comments and we will get you free of “Add to Compare” for ever and ever.