Skip to main content
Back to Articles
MagentoMarch 31, 20254 min read

How to Completely Disable "Compare Products" in Magento 2

Magento's built-in Compare Products feature can add unnecessary clutter and slow down page loads. This guide shows you how to fully remove it using layout XML overrides, CSS rules, and a quick CLI deploy -- keeping your storefront clean and fast.

Why Disable the Compare Feature?

Magento ships with a Compare Products feature that lets shoppers place items side by side. While useful in some contexts, it often adds visual clutter, injects extra frontend scripts, and slows page rendering -- especially on niche or single-product stores where comparison makes little sense.

Removing it delivers three wins:

  • Cleaner UI: No extra buttons or links on product and category pages.
  • Better UX: Shoppers stay focused on purchasing instead of comparing.
  • Faster loads: Unused JavaScript and blocks are no longer rendered.

Step-by-Step Removal

Step 1: Remove Default Compare Blocks via Layout XML

Magento renders compare functionality through layout XML blocks. Override them in your child theme by creating or editing:

app/design/frontend/<Your_Theme>/Magento_Catalog/layout/default.xml

Add the following content:

<?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.sidebar" remove="true"/>
    <referenceBlock name="category.product.addto.compare" remove="true"/>
    <referenceBlock name="catalog.product.link.compare" remove="true"/>
    <referenceBlock name="catalogsearch.product.addto.compare" remove="true"/>
    <referenceBlock name="view.addto.compare" remove="true"/>
    <referenceBlock name="related.product.addto.compare" remove="true"/>
    <referenceBlock name="upsell.product.addto.compare" remove="true"/>
    <referenceBlock name="product.info.addto.compare" remove="true"/>
    <referenceBlock name="product.compare.link" remove="true"/>
  </body>
</page>

Step 2: Hide Remaining Buttons via CSS / Less

Some themes may still render compare buttons through JavaScript or templates. Catch any stragglers with CSS:

app/design/frontend/<Your_Theme>/web/css/source/_extend.less
.action.tocompare,
.compare,
a[href*="product_compare"],
li[class*="compare"] {
  display: none !important;
}

Step 3: Deploy Your Changes

Run the following from the Magento root directory:

bin/magento setup:upgrade
bin/magento setup:static-content:deploy -f
bin/magento cache:clean

Verifying the Removal

  • Browse category pages -- compare links should be gone.
  • Open a product detail page -- the compare button should no longer appear.
  • Check search results -- compare options should be absent.

Tip: Test in a private/incognito window or clear the browser cache to see the updates immediately.

Going Further

Removing Compare Products is a quick win for stores that do not need it, especially niche or single-product shops. This approach works on Magento 2.4.7 and above with most themes. If you need more advanced storefront optimizations, we at Private DevOps are happy to help.

Need help with this?

Our team handles this kind of work daily. Let us take care of your infrastructure.