Magento: Programmatically Remove Layout Block
This article shows how you can remove layout blocks through the PHP Program instead of working in the layout.xml file in Magento 2. I will be using event observer. app/code/Company/Module/etc/frontend/events.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event name="layout_generate_blocks_after"> <observer name="remove_block" instance="Company\Module\Model\Observer\RemoveBlock" /> </event> </config> app/code/Company/Module/Observer/RemoveBlock.php Here, I am checking if a customer is logged in or … Read more