在Magento Cronjob中发送带有pdf附件的电子邮件

在Magento Cronjob中发送带有pdf附件的电子邮件,magento,cron,magento-1.7,crontab,php,Magento,Cron,Magento 1.7,Crontab,Php,我有一个report.phtml,我渲染它来创建一个PDF文件,并每月将其发送到一些电子邮件 我正在尝试使用Magento Cronjob自动化此过程 我知道Magento具有处理cronjobs的内置功能,但该解决方案涉及一个模型。我试图用模型呈现报告,但一无所获 class MyModule_Model_Report extends Mage_Core_Model_Abstract { public function generateReport() { $

我有一个report.phtml,我渲染它来创建一个PDF文件,并每月将其发送到一些电子邮件

我正在尝试使用Magento Cronjob自动化此过程

我知道Magento具有处理cronjobs的内置功能,但该解决方案涉及一个模型。我试图用模型呈现报告,但一无所获

class MyModule_Model_Report extends Mage_Core_Model_Abstract
{

    public function generateReport()
    {
        $content = $this->getLayout()->createBlock(
                    'Mage_Core_Block_Template', 'mymodule.report', array(
                    'template' => 'mymodule/report/report.phtml',
                    )
                )->toHtml(); // nothing returns as we can't render layouts in model

        mail('test@test.com', 'monthly report', $content);// for now just testing email

        // rest of the PDF generation and emailing script            
    }

}
mymodule的config.xml

<config>
...
    <crontab>
        <jobs>
            <namespace_module>
                <schedule>
                    <cron_expr>0,15,30,45 * * * *</cron_expr>
                </schedule>
                <run>
                    <model>mymodule/Report:generateReport</model>
                </run>
            </namespace_module>
        </jobs>
    </crontab>
...
</config>
有人可以指导我如何在这种情况下创建cronjob吗


提前谢谢

在cronjob任务中打印的所有内容都将发送到系统标准输出。我不明白你想在哪里打印输出。如果您从控制台手动调用cron,如“php-f…/cron.php”,您应该会看到块html。@JiříChmiel实际上我是通过电子邮件发送phtml内容的。有什么想法吗?
class MyModule_ReportController extends Mage_Core_Controller_Front_Action
{

        public function generateReportAction()
        {
            $content = $this->getLayout()->createBlock(
                        'Mage_Core_Block_Template', 'mymodule.report', array(
                        'template' => 'mymodule/report/report.phtml',
                        )
                    )->toHtml(); // it returns the report.phtml contents

        mail('test@test.com', 'monthly report', $content); // for now just testing email

            // rest of the PDF generation and emailing script            
        }
}