Remove Compare from Product List in Magento 2.1.6 [duplicate]
-
10-10-2020 - |
Question
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.
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.
Solution
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
OTHER TIPS
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