I need to delete the compare button from product list but I don't know how to to do it in Magento 2.1.6. enter image description here

Under [vendor]/[theme]/Magento_Catalog/templates/product/

I deleted the following in list.phtml:

   $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); ?>'
       <?php /* @escapeNotVerified */ echo __('<i class="fa fa-refresh"> </i>') ?>

and deleted the following in listing.phtml

. '<a href="' . $block->getAddToCompareUrl($_product) . '" class="action tocompare">'
. '<span>' . __('Add to Compare') . '</span></a>

It didn't work.

  • Check in layout file Under [vendor]/[theme]/Magento_Catalog/layout/catalog_category_view.xml Jul 11, 2017 at 7:17
  • do not delete the code, use XML to remove Jul 11, 2017 at 7:29
  • @EmiproTechnologiesPvt.Ltd. I thought that catalog_category_vie‌​w.xml is for Product Detail Page, no? I already removed the button in that page but in the product list (widget?), the button is still there.
    – Dean
    Jul 11, 2017 at 7:40
  • @RamaChandran the solution there doesn't seem to work in 2.1.6 version
    – Dean
    Jul 11, 2017 at 8:01

2 Answers 2


I guess that you was try to comment the code on wrong phtml.,So,you should enable the template hind from admin and find out exact phtml for this section and then the commenting /delete the code

. '<a href="' . $block->getAddToCompareUrl($_product) . '" class="action tocompare">'
. '<span>' . __('Add to Compare') . '</span></a>

Also, Then you Should to flush cache using bin/magento cache:flush or delete all files from magentoApplicationDir/var/view_procescced

  • My bad. You were right, I was modifying the wrong phtml.
    – Dean
    Jul 12, 2017 at 1:38

Update your extended catalog_category_view.xml file and Find it at your extended theme path


To remove compare from listing Page use this code

<referenceBlock name="category.product.addto.compare" remove="true"/>

I hope this will help you if not then let me know


  • It didn't work in product list. I already removed the compare button in Product detail page. But in the product list, it is still there.
    – Dean
    Jul 11, 2017 at 7:38
  • run upgrade/deploy/cache commands once Jul 11, 2017 at 7:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.