Remove Product Compare Blocks from Sidebar in Magento 2

0
2300
Remove Product Compare Blocks from Sidebar in Magento 2
Remove Product Compare Blocks from Sidebar in Magento 2

For today tip, I would like to share with you how to remove product compare blocks from sidebar in Magento 2. Not only from sidebar but also remove from other locations as well.

Normally, you might not want to have the product compare block to display anywhere in your theme. It is just enabled by default in Magento 2.

From your module or theme, update your layout as following:

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

Refresh the page, you will see those product compare blocks and links are complete removed from the layout.

Have fun ~