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

Generating Thumbnails with Spatie Media Library in Laravel 11: A Step-by-Step Guide

Generating image thumbnails is a common requirement in web applications, especially when handling media-heavy content.…

8 hours ago

Enhancing Web Application Security with Laravel’s Built-In Features

In today’s digital landscape, web application security is paramount. As a powerful PHP framework, Laravel…

1 day ago

Magento 2 Extensions Digest October 2024 (New Release & Updates)

October was an exciting month for MageComp! From significant updates across our Magento 2 extension…

1 day ago

Improving Error Handling and Transition Management in Remix with useRouteError and useViewTransitionState

In modern web development, seamless navigation and state management are crucial for delivering a smooth…

1 week ago

Magento Open Source 2.4.8-Beta Release Notes

Magento Open Source 2.4.8 beta version released on October  8, 2024. The latest release of…

1 week ago

How to Create Catalog Price Rule in Magento 2 Programmatically?

Hello Magento Friends, Creating catalog price rules programmatically in Magento 2 can be a valuable…

2 weeks ago