8

I want to remove compare product and wish list block from left panel.

I don't want to change template. I am using 2columns-left.

in magento 1.x, We uses like following in layout file.

<cms_index_index>
   <reference name="left">
      <remove name="left.newsletter"/>
   </reference>
</cms_index_index>

What to do to remove block from magento 2.x?

19

Its almost the very same way

<referenceBlock name="block.name.wantoberemoved" remove="true"/>

Remove compare products from sidebar

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

Remove Wishlist from sidebar

<referenceBlock name="wishlist_sidebar" remove="true" />
3

In Magento 2, you can remove Compare products and Wishlist from sidebar blocks of Category Page through xml. You can remove it by adding a default.xml file to your theme in: theme_dir/Magento_Catalog/layout/default.xml

And add below XML

<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="sidebar.additional" remove="true"/>
 </body>
</page>
1

You can create new deafult.xml in your custom module and write below code to remove recent order block from Left sidebar

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="../../../../../../../../htdocs/lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <body>
     <referenceContainer name="sidebar.additional">
         <referenceBlock name="catalog.compare.sidebar" remove="true"/>
         <referenceBlock name="wishlist_sidebar" remove="true"/>
     </referenceContainer>
    </body>
</page>
1

The code works fine in Magento 2.1.1.

With little changes :

instead referenceBlock replace with referenceContainer

<referenceContainer name="block.name.wantoberemoved" remove="true"/>
1

What worked for me, even via admin "Layout XML Update" field, was the code

<referenceContainer name="sidebar.additional" remove="true" />
1

A quick note for Enterprise users: you may need to remove the "multiple wishlist" block as well:

<referenceBlock name="multiple-wishlist_sidebar" remove="true" />
  • Man, I could not get wishlist sidebar to go away on an EE site. This worked perfect. Thank you! – Corgalore Jun 27 '18 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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