Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically remove block from layout

I want to remove the product_options_wrapper block from the product view page according to the logedin user via frontend router controller.

I know that I can programmatically append a new block but I didn't find a remove function. :-(

Tried sth. like that

$this->getLayout()->unsetBlock('product_options_wrapper');

$this->getLayout()->getBlock('product.info')->remove('product_options_wrapper');

But nothing works.

like image 702
Andre Aus B Avatar asked Sep 30 '26 04:09

Andre Aus B


1 Answers

Inorder to remove a block using its parent block use the code below

$this->getLayout()->getBlock('product.info')->unsetChild('product_options_wrapper');
like image 128
Rohit S Avatar answered Oct 02 '26 09:10

Rohit S