如果你特林同時擁有「新秩序」和「經銷商」模板 ,要完成這一辦法之一是:
創建擴展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
管理菜單>系統>配置>客戶配置>創建新帳戶選項。
@@ Rs非常感謝您的詳細解答!我也會試試這個 – kost