Actually I want to remove add to compare in catalog search result page

  • 1
    Hello, @hitesh if any of answer solves your concern then mark as accepted which will help future readers, thanks. Commented Oct 16, 2018 at 12:25

5 Answers 5


you should add below code in your Magento_Theme/layout/default.xml file :

<referenceBlock name="catalog.compare.link" remove="true"/>
<referenceBlock name="catalog.compare.sidebar" remove="true"/>

This will delete from everywhere.

  • i want to remove in search result page for products in custom theme magento 2 Commented Oct 11, 2018 at 6:09
  • if you add this piece of code in your theme's default.xml file it will remove from all places, however if you want to remove only from specific section then you should use this code in the required module / section layout. Commented Oct 11, 2018 at 6:19

You need to add : <referenceBlock name="catalogsearch.product.addto.compare" remove="true"/>

into: .../layout/catalogsearch_result_index.xml


I think the following links will help you in achiveing the same

https://bsscommerce.com/blog/how-to-disable-compare-in-magento-2-full-tutorial/ Magento 2: Safe and easiest way to disable Compare products & Wishlist Module

  • Please don't put single links, Describe about your solution
    – Amit Bera
    Commented Oct 11, 2018 at 10:20

Disable compare in Layer Navigation:

Compare products block is defined in


Now add a default.xml file to your theme in


Then remove your block as following:

 <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>

Disable compare in Product Page and Category Page:

  • You add the following xml instruction to your theme’s default xml file:

The xml file of your theme is located in






if you want to disable or remove add to compare option from frontend side

you can do the following

go to app/design/frontend/Vendor/theme/Magento_Theme/layout/default.xml

add below line just after body tag

<referenceBlock name="catalog.compare.sidebar" remove="true"/>

run this command

php bin/magento cache:clean && php bin/magento cache:flush

it will remove from catalog product listing as well as from search result

Your Answer

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

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