我为自定义模块创建了一个电子邮件模板,将文件放入app/locale/en_US/template/email
并在我的模块配置 XML 文件中进行了配置。现在我想通过代码在控制器中检索该模板。我试过了 :
$emailTemplate = Mage::getModel('core/email_template')->loadByCode('custom_template');
但它会返回一个NULL
电子邮件模板。我的模块电子邮件模板配置是:
<global>
<template>
<email>
<custom_template>
<label>Some custom email template</label>
<file>custom_template.html</file>
<type>html</type>
</custom_template>
</email>
</template>
</global>
我错过了什么?
**编辑**
我找到了这段代码,但是这条线
$template_collection = Mage::getResourceSingleton('core/email_template_collection');
返回一个空集合。我试图查看 Magento 的管理源代码,发现Mage_Adminhtml_Block_System_Email_Template_Grid
它也使用同一行来获取集合,显然,它适用于 Magento,但不适用于我的代码。为什么?