4

I have followed other tags and I have the following code in my default.xml in my child theme. All the other compare functions are disabled with this code except for on the product page. Why won't this disable compare on the product page?

<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"/>
    <referenceBlock name="catalog.compare.link" remove="true"/>
    <referenceBlock name="related.product.addto.compare" remove="true"/>
    <referenceBlock name="view.addto.compare" remove="true"/>
    <referenceBlock name="upsell.product.addto.compare" remove="true"/>
</body>
</page>
3
  • 1
    I would advise you to enable template block hints in Admin -> Store -> Configuration -> Advanced -> Debug. Find the block name which loads the compare functionality you wish to disable and then add it to your default.xml the same way you removed these other compare blocks.
    – Lez
    Commented Dec 29, 2017 at 10:04
  • Is not disabled products listing page or product details(view) page?
    – Abdul
    Commented Dec 29, 2017 at 12:29
  • when I turn on hints the path is app/design/frontend/Infortis/base/Magento_Catalog/templates/product/view/addto.phtml (but I can't find anything that refers to compare in that file) and the block shows: Magento\Catalog\Block\Product\View\Interceptor.
    – Rad Factor
    Commented Dec 30, 2017 at 14:11

3 Answers 3

4

you need Magento_Catalog/layout/catalog_product_view.xml with the following code to remove the link on the product page:

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

Not tested yet !

2
  • 1
    This cannot be because catalog.compare.sidebar is not in catalog_product_view.xml .
    – P S
    Commented Dec 29, 2017 at 17:36
  • As you can see in my code snippet.... I already added these to the default.xml
    – Rad Factor
    Commented Dec 30, 2017 at 13:25
1

Add this code in Magento_Catalog\layout\catalog_product_view.xml file

 <referenceBlock name="view.addto.compare" remove="true"/>

clear cache and check

0

Add this to remove from product page in default.xml

<referenceBlock name="product.info.addto" remove="true"/>

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.