In the last blog post, we have discussed How to disable the Wish List feature in Magento 2. All of us know how Magento 2 is powerful with so many features. But likes Wish List, Compare Products functionality is irrelevant for many store owners.
Magento 2 has a function that permits customers to compare products in the catalog. Compare Products generates a detailed, side-by-side comparison of two or more products. You can customize the report to include additional attributes or remove ones that you don’t want to include. Depending on the theme, the Add to Compare link might be represented by an icon or text.
For example, there is a built-in feature to allow customers to compare the products. It is a very useful functionality if you are selling items like appliances, machines, software, etc for which the purchase decision depends on the features and price balance. In such cases, the customers need the “compare products” feature to check the feasibility.
This tutorial will guide you step by step how to Disable Compare Products in Magento 2 site by making a few modifications.
Method to Disable Compare Products in Magento 2:
Create a default.xml file in Vendor/Module/view/frontend/layout and copy the below code:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<?xml version="1.0"?> <page layout="3columns" 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="catalogsearch.product.addto.compare" remove="true"/> <referenceBlock name="category.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> |
That’s it.
Any doubts? Feel free to mention them in the Comments section below. I’d be happy to help.
Thank you.