1

I would like to remove the comparison feature from catalog pages. I enabled developer hints for the template and found that the file containing the comparison icons was located at:

vendor/magento/module-catalog/view/frontend/templates/product/list/addto/compare.phtml

I then went ahead and created a file in my theme directory as follows:

app/design/fronted/Whistlefish/Magento_Catalog/view/frontend/templates/product/list/addto/compare.phtml

However there is no difference on the frontend. Assuming I've got the folder structure wrong, but I double checked and it looked ok?

2 Answers 2

0

You are in wrong phtml, you could found the declaration in vendor/magento/module-catalog/view/frontend/layout/catalog_product_view.xml

<block class="Magento\Catalog\Block\Product\View" name="product.info.addto" as="addto" template="product/view/addto.phtml"/>

You need to override that phtml in your custom theme. just copy addto.phtml in app/design/frontend/vendor/theme/Magento_Catalog/templates/product/view/addto.phtml after that remove or comment compare link.

Remove or comment below line

<a href="#" data-post='<?php /* @escapeNotVerified */ echo $compareHelper->getPostDataParams($_product);?>'
        data-role="add-to-links"
        class="action tocompare"><span><?php /* @escapeNotVerified */ echo __('Add to Compare') ?></span></a>

remove var/cache var/page_cache as well as browser cache before tested otherwise old cache files only get display. it perfectly work I have tested

screenshot for your easy reference

0

If you want remove compare feature in catalog page :

Go to our custom theme:

app/design/frontend/vendor/theme/Magento_Catalog/layout/default.xml

add below line:

   <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc   /page_configuration.xsd">
      <body>
         <referenceBlock name="catalog.compare.sidebar" remove="true"/>
      </body>
  </page>

then,

Remove var/*

<magento-root> $ rm -rf var/* 

remove  var/cache, var/page-cache, va/generation,var/log,..

check it. i hope this is useful for you.

3
  • Thanks - what do you mean Remove var/* ? Sep 19, 2016 at 15:48
  • @JoeAinsworth I update my answer Sep 19, 2016 at 16:00
  • I've tried this but to no success. The template hint is showing the file at /var/www/public/vendor/magento/module-catalog/view/frontend/templates/product/list/addto/compare.phtml. As per your suggestion I created a file in /var/www/public/app/design/frontend/Whistlefish/theme/Magento_Catalog/layout/catalog_category_view.xml. I then used rm -rf var/* but the compare feature was still present. Sep 19, 2016 at 18:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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