Magento Tutorials

How to Disable Compare Products for Magento 2

Hello, Magento Friends!

Magento 2 comes with various traits that might or might not benefit us. One such functionality is to compare products. With this utility, the specifications of two or more products can be easily demonstrated to customers. 

Let’s dive deep in!

What are Compare Products?

The Compare Products functionality lets us show the user detailed information of two or more products that are alike in category and characteristics. Two or more products are placed adjacent to each other to demonstrate clear segregation between them to the end-user. This functionality of comparing products is built-in. 

So if you have a store which sells appliances, software or machines then this might be a good fit for your business as the customers need to compare two products in terms of their features and the range of price. On the other hand, if your store is of clothing and accessories then you might not require this feature as its buying depends mostly on the person’s likings and the availability of size.

Let’s get into the method to disable Compare Products in Magento 2

Method to Disable Compare Products for Magento 2

Create a default.xml file in the below-given path:

app\design\frontend\Themes\Yourtheme\Magento_Catalog\layout\

Now, add the below-given 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="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! You’re good to go.

Wrapping It Up!

Integrate the above code and you will be able to disable the Compare Products seamlessly. Still, if you face any challenges with not getting proper results, you can reach out to us via the comments section below. 

If you are looking to make your store fully Magento featured and don’t have the know-how of Magento, then Hire a Dedicated Magento Developer who can custom-develop your Magento store.

Happy Coding!

Click to rate this post!
[Total: 7 Average: 5]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

Recent Posts

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

20 hours ago

How Upcoming Cookie Changes Will Affect Your E-commerce Website?

The e-commerce world is constantly in flux. New tech and strategies emerge daily to help…

20 hours ago

Magento 2: How to Add Header and Footer in Checkout

Hello Magento Friends, In today’s blog, we will discuss adding a header and footer to…

2 days ago

Understanding Flexbox Layout in React Native

Hello React Native Friends, Building a visually appealing and responsive mobile app is crucial in…

4 days ago

HYVÄ Themes Releases: 1.3.6 & 1.3.7 – What’s New

We're thrilled to announce the release of Hyvä Themes 1.3.6 and 1.3.7! These latest updates…

4 days ago

How Modern E-Commerce Platforms Leverage Docker & Kubernetes for Scalability

Your e-commerce platform is surging - orders are rolling in, traffic spikes are becoming the…

5 days ago