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.
Related Articles
How to Boost Magento 2 Performance in a Few Easy Steps
Magento 2 delivers incredible flexibility for eCommerce, but without proper optimization it can become sluggish. This guide walks through ten proven DevOps strategies to dramatically speed up your store, from PHP upgrades and full-page caching to Varnish, Redis, CDN configuration, and ongoing code audits.
MagentoHow to Upgrade Magento 2 from 2.4.7 to 2.4.8
Keeping Magento current is critical for security, performance, and compatibility. This step-by-step guide walks developers through upgrading from Magento 2.4.7 to 2.4.8, covering system requirements, pre-upgrade checks, Git workflow, Composer commands, and post-upgrade validation.
MagentoHow to Create a Magento 2 Child Theme
Customizing a Magento 2 store without modifying core files is best accomplished through a child theme. This tutorial covers every step, from choosing a parent theme and setting up the directory structure to registering the theme, overriding styles and templates, and activating it in the admin panel.