Compare Products is one of the prominent functions of Magento 2. It can display the specifications of two or more products. In this article, I will show you how to disable Compare Products function in Magento 2.
Step by step
Step 1: Create default.xml file in app\design\frontend\Magento_Catalog\layout.
Step 2: In the default.xml file, add the following code:
<?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"/>
<referenceBlock name="category.product.addto.compare" remove="true"/>
<referenceBlock name="catalogsearch.product.addto.compare" remove="true"/>
<referenceBlock name="crosssell.product.addto.compare" remove="true"/>
<referenceBlock name="related.product.addto.compare" remove="true"/>
<referenceBlock name="upsell.product.addto.compare" remove="true"/>
<referenceBlock name="view.addto.compare" remove="true"/>
</body>
</page>
Save and run the following commands:
php bin/magento c:c
php bin/magento c:f
I have completed the instructions on how to disable the Compare Products function in Magento 2. Hope this guide helps you!