1

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

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

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.

2
  • i want to remove in search result page for products in custom theme magento 2 Oct 11 '18 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. Oct 11 '18 at 6:19
1

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

into: .../layout/catalogsearch_result_index.xml

0

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

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

Disable compare in Layer Navigation:

Compare products block is defined in

vendor/magento/module-catalog/view/frontend/layout/default.xml

Now add a default.xml file to your theme in

/Magento_Catalog/layout/default.xml

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

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

or

Magento_Catalog/layout/default.xml

Reference

0

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, privacy policy and cookie policy

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