Question

I am running a cron that will email the products sold report daily. The issue I am having is that when I create the blocks in the cron model, the grid template attempts to load from frontend design path:

CRIT (2): Not valid template file:frontend/base/default/template/report/grid.phtml

The path for the template should be: adminhtml/default/default/template/report/grid.phtml

My code to build the block is:

$layout = Mage::app()->getLayout();
$block = $layout->createBlock('adminhtml/report_product_sold');
$grid = $block->getChild('grid');
$html = $grid->toHtml();

I am sure I am just missing something obvious, but cannot fathom what at this point :(

Was it helpful?

Solution

Try with this right above your code, works for me

Mage::getDesign()->setArea(Mage_Core_Model_App_Area::AREA_ADMINHTML);
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top