【发布时间】:2013-01-14 23:18:03
【问题描述】:
我试图在我的模块控制器中发送交易电子邮件并在 magentos 后端进行配置。
这是我的尝试:
在我的 config.xml 中
under config/global
<template>
<email>
<customer_lowerprice_mail_toshop_template
translate="label" module="telllowerpricelink">
<label>The mail from the TellLowerPriceForm to the shop</label>
<file>tellLowerPriceLink/toShopMail.html</file>
<type>html</type>
</customer_lowerprice_mail_toshop_template>
</email>
</template>
在我的 system.xml 中
<?xml version="1.0" encoding="UTF-8"?>
<config>
<sections>
<customer translate="label" module="telllowerpricelink">
<groups>
<lowerprice_mail translate="label">
<label>Emails to tell a lower price</label>
<frontend_type>text</frontend_type>
<sort_order>5</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
<fields>
<toshop_template translate="label">
<label>Template for the lower price mail which will be sent to the shop</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_email_template</source_model>
<sort_order>3</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</toshop_template>
</fields>
</lowerprice_mail>
</groups>
</customer>
</sections>
</config>
在我的 install-0.1.0.php 中
$configValuesMap = array(
'customer/lowerprice_mail/toshop_template' =>
'customer_lowerprice_mail_toshop_template',
);
foreach ($configValuesMap as $configPath=>$configValue) {
$installer->setConfigData($configPath, $configValue);
}
最后是我的控制器:
$this->toShopTemplateId = Mage::getStoreConfig('customer/lowerprice_mail/toshop_template');
var_dump($this->toShopTemplateId);
// output: customer_lowerprice_mail_toshop_template
$this->toShopSubject = 'my test subject';
/* Will be set with the submitted mailaddress of the user */
$this->toShopSender = 'test@me.com';
$this->toShopRecipients = 'test2@me.com';
$toShopMailVars = Array(
);
/* instantiating the mailtemplatemodel and sending it */
$toShopMail = Mage::getModel('core/email_template')
->setTemplateSubject($this->toShopSubject);
var_dump($toShopMail->getId());
//output: NULL
那么为什么我没有得到带有 ID 的交易邮件模板,该 ID 出现在我的配置字段中的 magento 后端?很抱歉很明显
非常感谢
【问题讨论】:
-
后端选中选项的值为“customer_lowerprice_mail_toshop_template”。但是在 /app/code/core/Mage/Core/Email/Template.php 中 sendTransactional 方法中的条件如下:
if (is_numeric($templateId)) { $this->load($templateId);
标签: magento configuration adminhtml transactional-email