马恩托交易电子邮件模板


Magento Transactional Email Template

我目前正在完成一个自定义控制器,以接受Ajax的报价表请求。我已经能够成功设置所有内容,并且它正在正确发送。我的问题与链接从 CMS 到我设置的控制器的事务性电子邮件模板。

我在Magento安装的语言环境中有一个模板,并且能够将其加载到后端的事务电子邮件管理器中。如何获取该模板的 ID 并将其加载到邮件对象中?我尝试使用简单的数字 id,但这似乎不起作用。

配置.xml

    <global>
    <template>
        <email>
            <custom_quote>
                <label>Custom Quote Form</label>
                <file>custom-quote.html</file>
                <type>html</type>
            </custom_quote>
            <trade_printer>
                <label>Trade Printer Form</label>
                <file>trade-printer.html</file>
                <type>html</type>
            </trade_printer>
        </email>
    </template>
    </global>
这是

使用电子邮件模板发送电子邮件的示例代码

$emailTemplate  = Mage::getModel('core/email_template')
                        ->loadDefault('custom_quote');                                  

$emailTemplateVariables = array();
$emailTemplateVariables['myvar1'] = 'Branko';
$emailTemplateVariables['myvar2'] = 'Ajzele';
$emailTemplateVariables['myvar3'] = 'ActiveCodeline';
$processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
$emailTemplate->send('john@someemail.com','John Doe', $emailTemplateVariables,$storeId=null);

参考

在阅读了可用的方法后,我发现 loadDefault()将始终从区域设置代码库加载模板。使用具有事务性电子邮件编辑器中指定的名称的loadByCode()将加载自定义模板。

最终代码

$emailTemplate = Mage::getModel('core/email_template')->loadByCode('Template Name Here');