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 ?

closed as off-topic by sv3n, Manoj Deswal, Jai, liyakat, Prince Patel Oct 24 '17 at 5:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced OR seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – sv3n, Manoj Deswal, liyakat
If this question can be reworded to fit the rules in the help center, please edit the question.


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

$orderItemBlock = Mage::app()->getLayout()->createBlock('sales/order_email_items', 'items')
$orderSubTotalBlock = Mage::app()->getLayout()->createBlock('sales/order_totals', 'order_totals')
$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())

Thanks, Vinith

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