Disable "Add To Compare" button in Magento

Disable "Add To Compare" button in Magento

September 4, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Disable "Add To Compare" button in Magento

Disabling the “Add To Compare” Button in Magento

As a senior developer, I often receive queries regarding customizations in e-commerce platforms like Magento. One common request is to disable or remove specific functionality such as the “Add To Compare” button.

Understanding the “Add To Compare” Feature

The “Add To Compare” feature allows customers to compare multiple products on your store by adding them to a comparison list. This can be helpful for shoppers who are trying to decide between similar items. However, in some cases, you might want to disable this functionality.

Disabling the Button on Hover in Magento 2

In Magento 2, the “Add To Compare” button is enabled by default and appears when a user hovers over a product. To disable it, we need to modify core files or implement an observer event.

You can manually edit the catalog_product_view.xml file located at app/design/frontend/Vendor/Theme/Magento_Catalog/layout/catalog_product_view.xml:

<referenceBlock name="catalog.product.view.addto.hover">
    <action method="setIsVisible">
        <argument name="is_visible" xsi:type="boolean">false</argument>
    </action>
</referenceBlock>

This code sets the visibility of the “Add To Compare” block to false, effectively disabling it.

However, modifying core files is generally not recommended as it can lead to issues during updates. If you choose this method, make sure to keep a backup and understand that your changes might need to be reapplied after each update.

The preferred approach is to use an event observer to disable the button programmatically. You can create a new module and implement an observer for the catalog_product_view_addto event:

class DisableAddToCompare
{
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        /** @var \Magento\Catalog\Model\Product $product */
        $product = $observer->getEvent()->getProduct();
        if ($product->getId()) {
            $block = $observer->getBlock();
            $block->setIsVisible(false);
        }
    }
}

In this code, we check if a product is present in the event. If it is, we set the visibility of the block to false using the setIsVisible method.

Implementing and Enabling Your Customization

To use this observer, you would need to create your own module following Magento’s extension development guidelines. The observer should then be configured to listen for the catalog_product_view_addto event in your module’s etc/events.xml file:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="catalog_product_view_addto">
        <observer name="disable_add_to_compare" instance="YourVendor\YourModule\Model\DisableAddToCompare"/>
    </event>
</config>

Once configured, flush your cache and the “Add To Compare” button should no longer appear when hovering over products on your store.

Conclusion

In conclusion, while Magento provides extensive customization options out of the box, sometimes you may need to disable certain features like the “Add To Compare” button. Whether you choose to modify core files or implement an observer event, it’s crucial to understand that these changes require careful testing and management during updates.

If you’re interested in learning more about Magento development best practices, I recommend checking out our comprehensive guide at Laravel Company. We cover everything from module creation to performance optimization.

Magento 2 Catalog Extensions Themes

Our network