🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Disable Compare Products in Magento 2

By Sanjay JethvaUpdated on May 22, 2025 1 min read

Magento 2 offers a vast range of functionalities to make the most out of the platform. However, you may not need them all! It depends on the type of business and its requirements that you chose the features to include or not.

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.

However, if you are selling apparel, the purchase decision depends on the choice, liking, size availability, etc. and the customers do not need to compare two dress’ features, isn’t it!

Unfortunately, the default functionality does not allow to simply disable compare products in Magento 2. So, I’ve come up with a programmatic solution that allows to remove compare product functionality.

Method to Disable Compare Products in Magento 2:

Create default.xml file in Vendor/Extension/view/frontend/layout  and copy the below code:

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

Please share the above solution with the fellow developers via social media.

Thank you.

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.