I want to remove 'Add To compare' links all over the website. The Add To Compare module is irrelevant for me. I am using Magento 2.2.0 version.
6 Answers
You can remove it by adding this line in your catalog_category_view.xml:
<referenceBlock name="category.product.addto.compare" remove="true" />
-
This is the right answer for removing the "Add to compare" link from the products in category page. Apr 23, 2019 at 14:17
Could you please catalog.compare.link in your default.xml find below path.
app\design\frontend\Magento\theme\Magento_Theme\layout
You can remove it by adding a default.xml file to your theme in: /Magento_Catalog/layout/default.xml
<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>
To remove the 'Add to compare' link from your product details page, you can add the foll lines to the catalog_product_view.xml file you place in:
app/design/frontend/(Vendor)/(themename)/Magento_Catalog/layout
XML code:
<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" />
</body>
</page>
This way you can keep your settings apart from each other, so the removal will be set in de file it belongs to.
Please add catalog.compare.link in your default.xml find below path - >
app\design\frontend\Magento\theme\Magento_Theme\layout
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<referenceBlock name="catalog.compare.link" remove="true"/>
<referenceBlock name="catalog.compare.sidebar" remove="true"/>
enter code here
</body>
</page>
Connect via SSH and run the following commands in the root folder:
Step 1: php bin/magento module:enable Mage_DisableCompare
Step 1: php bin/magento setup:upgrade