How to remove Add To Compare feature from Magewnto 2

Formatting looks :+1:

As for removing that icon. I don’t know the answer exactly, but these are the steps I would take…

Find reference references in vendor/magento/magento-catalog

I chose to look at the HTML Source in Chrome and find a reference to search for. I chose “add-to-links”. Then in SSH I ran the below command to find files with that line in it (not it’s case sensitive):

grep -Rl 'add-to-links' vendor/magento/module-catalog

And the results were:

vendor/magento/module-catalog/view/base/web/template/product/list/listing.html
vendor/magento/module-catalog/view/frontend/templates/product/listing.phtml
vendor/magento/module-catalog/view/frontend/templates/product/compare/list.phtml
vendor/magento/module-catalog/view/frontend/templates/product/view/addto.phtml
vendor/magento/module-catalog/view/frontend/templates/product/view/addto/compare.phtml
vendor/magento/module-catalog/view/frontend/templates/product/widget/new/content/new_grid.phtml
vendor/magento/module-catalog/view/frontend/templates/product/widget/new/content/new_list.phtml
vendor/magento/module-catalog/view/frontend/templates/product/list/items.phtml
vendor/magento/module-catalog/view/frontend/templates/product/list.phtml

Viewing the files

I think the most obvious file is new_list.phtml as the HTML appears to line up with what’s in the page source. Plus the name appears to be related. I think you’d want to override this file by putting it in your child theme. Experiment with stuff such as:

  • Line 27: Change $showCompare from true to false
  • Line 117-121: Comment out or delete

Note: Line 115 looks like the Compare Icon is shown based on some sort of logic. It seems to imply that there’s a setting somewhere (if ($block->getAddToCompareUrl() && $showCompare)). Or maybe it’s simply referencing Line 27.

I’m sure you can work the rest out yourself.