大家好!:)
我正在使用php脚本向客户群发送包含新凭据的电子邮件。
我使用并发送电子邮件的命令如下:
$customer->sendNewAccountEmail();
这会向客户发送一封电子邮件,并使用名为“新帐户”的模板
问题是我创建了一个新的自定义模板 称为将密码发送给转销商模板
那我怎么能运行这个命令呢
$customer->sendNewAccountEmail();
但是使用我的新模板?
答案 0 :(得分:1)
您需要修改数据库中的选项以使用新模板:
答案 1 :(得分:1)
如果您想要同时拥有“新订单”和“转销商”模板,那么实现此目标的一种方法是:
创建一个扩展Mage_Customer_Model_Customer
class MagePal_ResellerCustomer_Model_Customer extends Mage_Customer_Model_Customer
const XML_PATH_REGISTER_RESELLERS_EMAIL_TEMPLATE = 'customerreseller/create_account/email_template';
public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
{
$types = array(
'registered' => self::XML_PATH_REGISTER_RESELLERS_EMAIL_TEMPLATE, // welcome email, when confirmation is disabled
'confirmed' => self::XML_PATH_CONFIRMED_EMAIL_TEMPLATE, // welcome email, when confirmation is enabled
'confirmation' => self::XML_PATH_CONFIRM_EMAIL_TEMPLATE, // email with confirmation link
);
if (!isset($types[$type])) {
Mage::throwException(Mage::helper('customer')->__('Wrong transactional account email type'));
}
if (!$storeId) {
$storeId = $this->_getWebsiteStoreId($this->getSendemailStoreId());
}
$this->_sendEmailTemplate($types[$type], self::XML_PATH_REGISTER_EMAIL_IDENTITY,
array('customer' => $this, 'back_url' => $backUrl), $storeId);
return $this;
}
向您的模块添加系统配置,以便您可以选择自定义电子邮件模板(请参阅Custom Magento System Configuration)
在system.xml中
<email_template>
<label>Email Template</label>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<sort_order>5</sort_order>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_email_template</source_model>
</email_template>
然后发送您的电子邮件
if(customer group == reseller):
$customer = Mage::getModel('resellercustomer/customer')->load($customer_id)
$customer->sendNewAccountEmail();
else
$customer = Mage::getModel('customer/customer')->load($customer_id)
$customer->sendNewAccountEmail();
如果您只想使用新模板,请查看 @ Customizing Email Templates
管理员菜单&gt;系统&gt;配置&gt;客户配置&gt;创建新帐户选项。