50

I am building Magento 2.0 only to sell 2 of my products online. The compare products and wishlist module is irrelevant for me.

How I safely and easily remove those modules? I dont want to hack the core code.

18 Answers 18

71

In Magento 2, you can actually now remove Compare products functionality via xml file. Compare products block is defined in vendor/magento/module-catalog/view/frontend/layout/default.xml

and you can remove it by adding a default.xml file to your theme in: <theme_dir>/Magento_Catalog/layout/default.xml

inside which you remove your block 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.sidebar" remove="true"/> 
        <referenceBlock name="wishlist_sidebar" remove="true" />
    </body>
</page>
8
  • Worked like a charm. Magento 2.0.6
    – camdixon
    Commented Jun 17, 2016 at 16:00
  • FYI, here's the exact location of the instructions: devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/…
    – thdoan
    Commented Jun 24, 2016 at 9:12
  • 12
    Its not working in version 2.1.X
    – Jarnail S
    Commented Dec 12, 2016 at 6:57
  • What about removing the My Wish List block? Commented Oct 25, 2017 at 16:48
  • You can add this to remove the wishlist block from the sidebar: <referenceBlock name="wishlist_sidebar" remove="true" />
    – Frank
    Commented Apr 6, 2018 at 10:49
45

I grepped the source for all compare blocks. For 2.3 this is the complete list. This will also remove the compare link from the header.

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <!-- Remove compare -->
        <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>
6
  • 1
    This works perfectly without having to modify any source files that could change in future updates.
    – PedroKTFC
    Commented Mar 6, 2019 at 17:16
  • This should go into default.xml of a custom theme right? Commented May 29, 2019 at 15:53
  • What command did you use to grep the correct lines? Commented Dec 4, 2019 at 13:05
  • 2
    This worked for me, thank you. It really is crazy that they don't just have a setting for this change.
    – S Adamson
    Commented Dec 13, 2019 at 2:15
  • didn't work for 2.3.3 for me
    – artgrohe
    Commented Apr 3, 2020 at 12:49
40

You can add following xml instruction to either your custom theme's default xml file which should be located at /app/design/frontend/Vendor/theme/Magento_Theme/layout/default.xml or to Magento_Catalog/layout/default.xml file in your custom theme:

    <referenceBlock name="catalog.compare.sidebar" remove="true"/>
    <referenceBlock name="view.addto.compare" remove="true" />
    <referenceBlock name="view.addto.wishlist" remove="true" />

which gets rid of

  • sidebar compare block
  • compare block from product details page
  • add to wishlist from product details page

To remove add to compare from category pages (catalog product list) use:

<referenceBlock name="category.product.addto.compare" remove="true"/>
2
  • 5
    Great answer, you also need to add <referenceBlock name="category.product.addto.compare" remove="true"/> to remove link from catalog product list. Commented Aug 20, 2017 at 17:53
  • 1
    Thanks for your answer, you've missed to add also <referenceBlock name="catalogsearch.product.addto.compare" remove="true"/> that removes the compare function also from catalog search results. Commented Apr 10, 2019 at 8:12
13

Wishlist can be disabled from

store > Configurations > Customers > Wish List> General options> Enabled: No.

8

Disable Wishlist on Stores > Configuration > Customers > Wishlist and to disable the Compare function paste this lines below on Magento_Catalog/layout/default.xml of your theme.

<?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.link" remove="true"/>
        <referenceBlock name="catalog.compare.sidebar" remove="true"/>
    </body>
</page>

Set $showCompare to false in the following templates:

Magento/Catalog/view/frontend/templates/product/list/items.phtml Magento/Catalog/view/frontend/templates/product/widget/new/content/new_grid.phtml Magento/Catalog/view/frontend/templates/product/widget/new/content/new_list.phtml Magento/Catalog/view/frontend/templates/product/widget/content/grid.phtml

Remove compare related staff from the following templates:

Magento/Catalog/view/frontend/templates/product/list.phtml Magento/Catalog/view/frontend/templates/product/listing.phtml Magento/Wishslist/view/frontend/templates/item/configure/addto.phtml

Reference: https://coderwall.com/p/vsqmbw/remove-product-compare-functionality-on-magento-2-frontend

1
  • As of 2.1.x this solution is probably the most well put together. Commented Feb 14, 2017 at 16:08
7

Magento provide command line utility for it example

php bin/magento module:disable -f Magento_Wishlist

as Magento wishlist depend upon the other module as well so using without [-f] will not disable or enable the module and will display warning like

enter image description here

after using command with [-f] flag will solve this issue

enter image description here

please check the warning when you are using command forcefully

Alert: You used the --force option. As a result, modules might not function properly.

You may check complete information here as well http://devdocs.magento.com/guides/v2.0/install-gde/install/cli/install-cli-subcommands-enable.html#instgde-cli-subcommands-enable-modules

3
  • Thanks. Your answer looks promising but I am bit nervous... Will this not break any other functionality? Commented Jan 13, 2016 at 17:19
  • You can try the same in Test Instance , it should not brake mainly permission will change that need to be altered
    – webkul
    Commented Jan 13, 2016 at 17:38
  • It will not break functionality. All those plugins listed in red use compare products, but without the plugin enable the compare products features in the other plugins will not display or be used. Commented Sep 12, 2020 at 20:00
6

UPDATE: After a Magento 2 core update, klara's answer is now the best way to disable Compare functionality. Please read below !

To disable Wish List functionality, you need to go in the administration, under Stores > Configuration > Customers > Wish List and choose Enabled : No.

To disable Compare functionality, there's no option in the administration. You need to override the module-catalog/view/frontend/templates/product/list.phtml template.

To do so, you need to copy the content of the file I named above in a new file inside your theme located under <theme_dir>/Magento_Catalog/templates/product/list.phtml. Then, you want to remove the concerned lines :

<?php
$compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare');
?>
<a href="#"
   class="action tocompare"
   title="<?php echo $block->escapeHtml(__('Add to Compare')); ?>"
   aria-label="<?php echo $block->escapeHtml(__('Add to Compare')); ?>"
   data-post='<?php /* @escapeNotVerified */ echo $compareHelper->getPostDataParams($_product); ?>'
   role="button">
    <span><?php /* @escapeNotVerified */ echo __('Add to Compare') ?></span>
</a>

Those are at lines 111 to 121 in Magento 2.0.1

4

For Magento 2.1.x

Adding a default.xml file to your theme in: /Magento_Catalog/layout/default.xml

<?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="category.product.addto.compare" remove="true"/>
        <referenceBlock name="catalog.compare.sidebar" remove="true"/>
    </body>
</page>
1
  • add also <referenceBlock name="catalog.compare.link" remove="true"/> to remove link in top menu Commented Sep 29, 2017 at 4:39
3

to disable the sidebar:

<body>
  <referenceBlock name="catalog.compare.sidebar" remove="true"/>
</body>

to remove the "Add to compare" link on the product page you need to overwrite the Magento_Catalog/templates/product/view/addto.phtml file in your theme and remove the compare anchor there. This way you can keep the wishlist but remove the compare functionality.

3

This is an extension of other solutions provided here. Use the file /app/design/frontend/Vendor/theme/Magento_Theme/layout/default.xml and add the following

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

After trying all the above methods for the individual product pages, I found the one file that mattered in my case, with an installed theme, but utilizing my own child theme addtocart.phtml. Other options will work for the grid category view and list category view (the aforementioned list.phtml, but on individual product pages:

<a href="#" data-post='<?php /* @escapeNotVerified */ echo $compareHelper->getPostDataParams($_product);?>'
            data-role="add-to-links"
            class="action tocompare">
    <i class="fa fa-retweet icons"></i>
    <span><?php /* @escapeNotVerified */ echo __('Compare') ?></span>
</a>

This needs to be commented out. Hours and hours of trying and it was this file.

If anyone finds otherwise, please let me know!

1
  • find a solution.i l think my answer is best practice
    – Goldy
    Commented Apr 6, 2017 at 7:40
0

You can add the line: <referenceBlock name="catalog.compare.sidebar" remove="true"/> Magento -> administrator -> PRODUCTS -> Categories -> Custom Design -> Custom Layout Update

0

M2.1 quick and easy solution.
If you don't want to create a custom theme and/or prefer to work from the backend, you can do the following in the backend. Navigate to the cms page, category or product page you want to alter. Example for Category Page: under Design -> Layout Update XML add the following code:

<referenceContainer name="content">
    <referenceBlock name="catalog.compare.sidebar" remove="true" />
    <referenceContainer name="sidebar.additional" remove="true" />
 </referenceContainer>

Note: if you want additional blocks to remain in the sidebar, set the additional container to "false" like this:

 <referenceContainer name="content">
     <referenceContainer name="sidebar.additional" remove="false" />
 </referenceContainer> 
0

The wish list can be disabled via backend, as written in other answers.

There is a FOSS module which can remove the compare function on a per-store-view level:

https://github.com/Joshua29LK/disable-compare-magento-2

I did a short review:

  • It adds a layout handle to remove the compare blocks
  • This uses basically the same code as in the answers here (but is activated only on a store level)
  • The addto Link is removed by injecting CSS into the head, which sounds a bit strange but avoids replacing core templates
0

I am using the Ultimo theme on Magento 2.3.3. I couldn't disable the compare link from the theme's catalog_product_view.xml file as the settings are not coming from there but they are located in:

vendor/magento/module-catalog/view/frontend/layout/catalog_product_view.xml

I went for the quick and dirty solution, simply removed the following:

                    <container name="product.info.social" label="Product social links container" htmlTag="div" htmlClass="product-social-links">
                        <block class="Magento\Catalog\Block\Product\View" name="product.info.addto" as="addto" template="Magento_Catalog::product/view/addto.phtml">
                            <block class="Magento\Catalog\Block\Product\View\AddTo\Compare" name="view.addto.compare" after="view.addto.wishlist"
                                   template="Magento_Catalog::product/view/addto/compare.phtml" >
                                <arguments>
                                    <argument name="addToCompareViewModel" xsi:type="object">Magento\Catalog\ViewModel\Product\Checker\AddToCompareAvailability</argument>
                                </arguments>
                            </block>
                        </block>
                        <block class="Magento\Catalog\Block\Product\View" name="product.info.mailto" template="Magento_Catalog::product/view/mailto.phtml"/>
                    </container>

The compare button is gone forever, however if you perform a Magento upgrade it will come back so it will need to be removed again.

0

For Compare this is correct https://magento.stackexchange.com/a/253236/15747

For Wishlist, you can simply disable the HTML output by adding "system > Websites > base > advanced > modules_disable_output" to etc/app/config.php

This method avoids dependency issues as the module remains active but the output is disabled.

Note: My example includes other features that are commonly disabled.

<?php
return [
    'modules' => [
....
    ],
    'system' => [
        'websites' => [
            'base' => [
                'advanced' => [
                    'modules_disable_output' => [
                        'Magento_Downloadable' => 1,
                        'Magento_Review' => 1,
                        'Magento_Wishlist' => 1,
                        'Magento_SendFriend' => 1
                    ]
                ]
            ]
        ]
    ]
];

See: https://devdocs.magento.com/guides/v2.3/config-guide/config/disable-module-output.html

0

Add this to default.xml

<referenceBlock name="product.info.addto" remove="true"/>
0

Quick and dirty solution was to change the visibility of tocompare feature by appending the following in default.css

.tocompare{ visibility: hidden; }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.