0

Magento load layout handle directive programmatically

When I used the code given in the above link, It throws an error when cache is turned on. Noticed that this issue occurs when "Layouts" cache is enabled. This code is in the model class . I am using Magento 1.14 EE

Fatal error: Call to a member function setData() on boolean in ....

It works fine when:

  1. when cache is turned off.
  2. Runs perfectly when code in external script( in the root folder of magento) and cache is turned on.

Anyone faced this issue ?

1

Finally Solved. An alternative way. Please suggest if any.

$orderItemBlock = Mage::app()->getLayout()->createBlock('sales/order_email_items', 'items')
    ->setTemplate('email/order/items.phtml');
$orderSubTotalBlock = Mage::app()->getLayout()->createBlock('sales/order_totals', 'order_totals')
    ->setTemplate('sales/order/totals.phtml');
$orderTaxBlock = Mage::app()->getLayout()->createBlock('tax/sales_order_tax', 'tax')->setTemplate('tax/order/tax.phtml');
$orderSubTotalBlock->setChild('tax', $orderTaxBlock);
$orderItemBlock->setChild('order_totals', $orderSubTotalBlock);
$html = $orderItemBlock->setOrder($this->getObjectOfInput())
            ->addItemRender(
                'default',
                'sales/order_email_items_order_default',
                'email/order/items/order/default.phtml'
            )->toHtml();

Thanks, Vinith

Not the answer you're looking for? Browse other questions tagged or ask your own question.