Programmatically remove block from layout

后端 未结 3 730
逝去的感伤
逝去的感伤 2021-01-15 13:55

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 program

3条回答
  •  不知归路
    2021-01-15 14:33

    This should work:

        $blockName = 'left'; // Add yours
        $update = Mage::app()->getLayout()->getUpdate();
        $removeInstruction = "";
        $update->addUpdate($removeInstruction);
    

    Why? Have a look in the file Mage_Core_Model_Layout in the method generateXml() the XML is parsed and where a remove is set for a block, the attribute ignore is added to the block. In the method generateBlocks() all the blocks which have that attribute are not added.

提交回复
热议问题