簡體   English   中英

Magento需要向特定客戶組發送自定義帳戶確認電子郵件

[英]Magento need to send custom account confirmation email to specific customer group

我一直在瀏覽文件並撓頭。 發送新帳戶創建電子郵件的功能在哪里? 一旦找到它,我將使用什么變量來指代特定的客戶群?

編輯2/18根據下面的建議,我正在查看Customer.php文件,並看到以下功能:

 public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
    {
        $types = array(
            'registered'   => self::XML_PATH_REGISTER_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;
    }

我假設可以在$ types數組中設置其他類型,但是如何訪問常量const XML_PATH_REGISTER_EMAIL_IDENTITY ='customer / create_account / email_identity'來設置新的類型條件? 我還沒有弄清楚如何找到xml路徑。


編輯2/21

我已經復制了整個模塊文件並將其重命名,並將其創建為我自己的模塊。 我在配置文件中更改了以下內容:

<customer_create_account_email_template_dvm translate="label" module="customer">
                    <label>New account DVM</label>
                    <file>account_new_dvm.html</file>
                    <type>html</type>
                </customer_create_account_email_template_dvm>

要添加我的模板,這里也是第二個。

<create_account>
                <confirm>0</confirm>
                <default_group>1</default_group>
                <tax_calculation_address_type>billing</tax_calculation_address_type>
                <email_domain>example.com</email_domain>
                <email_identity>general</email_identity>
                <email_template>customer_create_account_email_template</email_template>
                <email_confirmation_template>customer_create_account_email_confirmation_template</email_confirmation_template>
                <email_register_template_dvm>customer_create_account_email_register_template_dvm</email_register_template_dvm>
                <email_confirmed_template>customer_create_account_email_confirmed_template</email_confirmed_template>
                <vat_frontend_visibility>0</vat_frontend_visibility>
            </create_account>

然后將常量添加到Customer.php

const XML_PATH_CONFIRM_EMAIL_TEMPLATE_DVM       = 'customer/create_account/email_confirmation_template_dvm';

和修改的功能:

public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
    {

        Mage::getSingleton('core/session', array('name'=>'frontend')); 
        $session = Mage::getSingleton('customer/session');

        //Caitlin Havener
        //What Group do you belong to?
        if($session->isLoggedIn()) {
            $customerGroupID = $session->getCustomerGroupId();
            print("Customer Group ID is ". $customerID);
        } else {
            echo 'Not logged In';
        }

        //If you are DVM set your type
        if ($customerGroupID==5)
        {
            $type = 'dvm';
        }

        $types = array(
            'registered'   => self::XML_PATH_REGISTER_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
            'dvm' => self::XML_PATH_REGISTER_EMAIL_TEMPLATE_DVM,   // dvm new account email
        );
        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;
    }

我測試了一下,它不起作用。 如您所見,我有一些回聲可以追蹤,但是我不確定如何直接調試它。 我有Firebug,但不知道如何使用它。 任何建議將不勝感激。 $ session-> isLoggedIn()的計算結果是否為假?

更新2月27日/ 13_1 _ __ _ __ __ _ _ _ __ __ _ __ _ __ __ _ _ _ __ __ _ __ __ _ _ _ __ __ @Meabed我試圖復制你的博客文章在做什么。 我創建了一個名為CaitlinHavener的文件夾,在其中放置了DVMCustomer目錄,並在其中放置了一個etc文件夾。 我里面有config.xml:

<template>
            <email>
                <CaitlinHavener_DVMCustomer translate="label" module="mymodule">
                    <label>DVMCustomer Template</label>
                    <file>custom/mytemplate.html</file>
                    <type>html</type>
                </CaitlinHavener_DVMCustomer>
            </email>
</template>

在system.xml中,我有:

<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<config>
    <sections>
        <customer translate="label" module="mymodule">
            <groups>
                <custom_email translate="label">
                    <label>DVM Custom Template</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>
                            <exist_user_template translate="label">
                                <label>DVM Custom Template</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>
                            </exist_user_template>
                    </fields>
                </custom_email>
            </groups>
        </customer>
    </sections>
</config>

我創建了一個名為CaitlinHavener_DVMCustomer.xml的模塊xml並將其放在modules文件夾中:

<?xml version="1.0" encoding="UTF-8"?>
<config>    
    <modules>
        <CaitlinHavener_DVMCustomer>
            <active>true</active>
            <codePool>local</codePool>
        </CaitlinHavener_DVMCustomer>
    </modules>
</config>

當我進入system> config> advanced時,我可以看到系統已注冊該模塊,但是當我進入system> transactional emails時,在那里或創建新模板並選擇“加載模板”時都看不到該模塊。

看到我做錯了嗎?

發送新帳戶郵件的配置可以在“系統”->“配置”->“客戶”組中找到,然后在“客戶”組中查找“客戶配置”。 您可以在此處找到“創建新帳戶”選項。

對於我所看到的客戶組,核心Magento僅允許在同一配置組中為每個storeview配置該選項。

您需要制作另一個模塊並擴展客戶模型

class Mage_Customer_Model_Customer extends Mage_Core_Model_Abstract

該模型具有與發送電子郵件有關的所有方法,因此您需要檢查客戶組並設置要發送的模板。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM