How to Remove Block From Layout in Magento 2

How to Remove Block From Layout in Magento 2

Magento 2 store designs must constantly be updated based on the business requirements, latest trends, and for the improvement of customer experience.

As a part of this process, you may require to add or remove a block from the layout in Magento 2. Here, I’ve shown how to remove block from layout in Magento 2 with a programmatic solution.

One can use this method in various ways. For example, the store is running a Christmas offer and had added a promotional offer block on the home page which needs to be removed post offer. Also, you may want to remove any default blocks for which the method is useful.

I’ve taken an example of removing the coupon code application block on the checkout page. If you want to remove a promo code that you are currently offering, you can do so by removing that block from the checkout.

Steps to Remove Block From Layout in Magento 2:

All you have to do is:

For example, remove the coupon code block from the checkout cart page:

In checkout_cart_index.xml,

That’s it.

Any doubts in the implementation? Mention them in the Comments section below and I’d be glad to help 😊

I’d be very grateful if you share this helpful post on social media to fellow developers!

Thanks!

5
(based on 6 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. When he is not engrossed with anything related to Magento, he loves to play cricket.

2 comments On How to Remove Block From Layout in Magento 2

  • I tried this, but it doesn’t seem to work. I’m using Magento 2.2.10.

    • Hello,
      Can you please share which block are you trying to remove and from which XML file? It would be easy to help you out if you share how you are adding the given code in the XML file.
      Thanks.

Leave a Reply