>How to Disable Compare in Magento 2 – Full Tutorial

How to Disable Compare in Magento 2 – Full Tutorial

Magento 2 offers various features for the online stores, even including the features that you don’t need at all. You want to disable the Add to Compare features, but there isn’t any built-in function to do this. This Magento 2 tutorial blog will guide you two simple ways to remove the compare product function.

You can use coding or a free Magento 2 Disable Compare extension to completely remove the “Add to Compare” feature on all pages and at all positions on products.

Option 1: How to Disable Compare Product Features Programmatically

Disable compare in Layer Navigation:

Compare products block is defined in

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

You add a

 <default.xml

file to your theme in

 <theme_dir>/Magento_Catalog/layout/default.xml

Then remove your block as follows:

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

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

 

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

Disable compare in Header:

Add the following XML instruction to Magento_Catalog/layout/default.xml of your theme:

 <?xml version="1.0"?> <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.link" remove="true"/> <referenceBlock name="catalog.compare.sidebar" remove="true"/> </body> </page>

Set $showCompare to false in the following templates:

 <Magento/Catalog/view/frontend/templates/product/list/items.phtml Magento/Catalog/view/frontend/templates/product/widget/new/content/new_grid.phtml Magento/Catalog/view/frontend/templates/product/widget/new/content/new_list.phtml Magento/Catalog/view/frontend/templates/product/widget/content/grid.phtml

Remove compare related staff from the following templates:

 <Magento/Catalog/view/frontend/templates/product/list.phtml Magento/Catalog/view/frontend/templates/product/listing.phtml Magento/Wishslist/view/frontend/templates/item/configure/addto.phtml

Option 2: Magento 2 Disable Compare Extension Free

BSSCommerce offers you the quickest, easiest and safest way to complete remove the compare button at all places. Magento 2 Disable Compare extension easily remove Add to Compare on Product Page, Category Page, Search Result Page, Layered Navigation, Widget, Related Product, Upsell Product, and Cross-sell Product.

magento-2-disable-compare-on-product-page
Remove “Add to Compare” function on Product Page

Moreover, Disable Compare extension is FREE – NO code interfere – NO code – NO bug. With the free Magento 2 Disable Compare extension, you can disable compare product function on all pages and at all positions completely with just 1 simple configuration.

magento-2-disable-compare-general-configuration
Simple configuration of Magento 2 Disable Compare extension

You can download the Magento 2 Disable extension free right here:

Magento 2

I hope that the tutorial blog is helpful for you to disable the compare product function in Magento 2. Please Like, Share, Subscribe and share your thoughts in the comment section below. BSSCommerce is always ready to assist you in case you have any question.

magento-2-disable-compare-extension