Question

I now work with sources of other developers and don't understand what for this code:

protected function _getShippingMethodsHtml() {
    $layout = $this->getLayout();
    $update = $layout->getUpdate();
    $update->load('opcheckout_onepage_shippingmethod');
    $layout->generateXml();
    $layout->generateBlocks();
    $output = $layout->getOutput();
    return $output;
}

I am highly appreciated for any help.

Was it helpful?

Solution

protected function _getShippingMethodsHtml() {
    $layout = $this->getLayout();
    $update = $layout->getUpdate(); //getLayout->getUpdate() you get the layout handle of your page, you can check it with this : <?php var_dump(Mage::app()->getLayout()->getUpdate()->getHandles());?>
    $update->load('opcheckout_onepage_shippingmethod'); //you load this layout handle : opcheckout_onepage_shippingmethod
    $layout->generateXml(); //generate a layout xml, see Mage_Core_Model_Layout
    $layout->generateBlocks(); //You create layout blocks hierarchy from layout xml configuration, see Mage_Core_Model_Layout
    $output = $layout->getOutput(); 
    return $output; //get a rendered block
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top