How to Remove Block Programmatically in Magento 2

In this tutorial, you will go through how to easily remove block programmatically in magento 2. This trick will be very useful and handy when you want to remove block programmatically with magento 2.

You can simply use unsetElement() method to remove block. as like

$layout = $this->getLayout();
$block = $layout->getBlock('catalog.topnav'); // block name

I hope you like this post, Please feel free to comment below, your suggestion and problems!

(Visited 16 times, 1 visits today)
Chandra Kumar

Hello World, I am Chandra Kumar from New Delhi, India. I am professionally developer, programmer and blogger. I am the founder of

0 Comment

Leave a Comment

Your email address will not be published. Required fields are marked *