4

This question already has an answer here:

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:

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

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.

marked as duplicate by liyakat, sv3n, Murtuza Zabuawala, Siarhey Uchukhlebau, Prince Patel Jul 11 '17 at 12:24

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Check in layout file Under [vendor]/[theme]/Magento_Catalog/layout/catalog_category_view.xml – Emipro Technologies Pvt. Ltd. Jul 11 '17 at 7:17
  • do not delete the code, use XML to remove – Manoj Deswal Jul 11 '17 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 '17 at 7:40
  • @RamaChandran the solution there doesn't seem to work in 2.1.6 version – Dean Jul 11 '17 at 8:01
1

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 '17 at 1:38
7

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

app/design/frontend/vendorname/themename/Magento_Catalog/layout/catalog_category_view.xml

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

Thanks

  • 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 '17 at 7:38
  • run upgrade/deploy/cache commands once – Manoj Deswal Jul 11 '17 at 7:39

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