我正在运行一个Cron,将每天通过电子邮件将售出的产品发送电子邮件。我遇到的问题是,当我在Cron模型中创建块时,网格模板尝试从前端设计路径加载:

CRIT(2):没有有效的模板文件:前端/base/base/default/template/report/grid.phtml

模板的路径应为:adminhtml/default/default/template/report/grid.phtml

我的构建块的代码是:

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

我敢肯定,我只是缺少明显的东西,但是在这一点上无法理解:(

有帮助吗?

解决方案

在您的代码上方尝试使用此权利,为我工作

Mage::getDesign()->setArea(Mage_Core_Model_App_Area::AREA_ADMINHTML);
许可以下: CC-BY-SA归因
scroll top