How to remove the compare products feature in Magento 2?

The customer does not always need all the functions that are offered in the store. It all depends on the type of products you are selling. This time we will focus on the Magento product comparison function. Sometimes buyers simply don't need to compare the characteristics of two products, for example, when it comes to clothing.

But not everything is so easy. As is often the case, Magento's default functionality does not allow you to disable the magento compare products feature. Therefore, there is only a programmatic solution to this issue. We provide a code with which you can solve the problem posed.

Warning: all code snippets in this article are examples. You need to customize them to suit your business needs.

Create the default.xml file in Vendor/Extension/view/frontend/layout and use the following code to remove Magento compare feature:

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

If you want to set up your store without any problems and without knowing programming skills, then the Jet Theme extension is what you need. It is responsive, fast, and provides wide out-of-box functionality. With it, you can:

  • add additional elements to different pages of your store
  • let users hide filtering options, enable quick view for catalog products
  • optimize images
  • customize your theme design with a style guide

And this is only a part of the functions. Check all others on the product page.

How can we help you?

Didn’t you find the answer to your question? We are always happy to help you out.