【问题标题】:Magento need to send custom account confirmation email to specific customer groupMagento 需要向特定客户群发送自定义帐户确认电子邮件
【发布时间】:2013-02-05 21:07:25
【问题描述】:

我一直在翻阅文件并摸不着头脑。发送新帐户创建电子邮件的功能在哪里?一旦我找到它,我会用什么变量来指代特定的客户群?

编辑 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___________________________________________ @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 并将其放在模块文件夹中:

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

当我进入系统>配置>高级时,我可以看到系统注册了模块,但是当我进入系统>事务性电子邮件时,我在那里看不到它,或者当我创建新模板并选择“加载模板”时。

你知道我做错了吗?

【问题讨论】:

    标签: php magento


    【解决方案1】:

    您需要制作另一个模块并扩展客户模型

    class Mage_Customer_Model_Customer extends Mage_Core_Model_Abstract
    

    模型有发送邮件相关的所有方法,所以你需要检查客户群并设置你要发送的模板。

    【讨论】:

    • 我在上面编辑过。如何找到那个 xml 路径?或者你有更好的建议吗?
    • 检查如何在 XML 中定义电子邮件模板,然后在修改后的文件中使用它! magentocommerce.com/wiki/5_-_modules_and_development/reference/…
    • 你能看看我上面做了什么,看看有没有什么吸引你的眼球?谢谢!
    • 很可能你在 xml 中有错误的标签,冷静!生病做模块,今天给你发链接:)
    • 你看了吗? :D
    【解决方案2】:

    发送新帐户邮件的配置可以在系统->配置->然后在左侧边栏中的客户组中找到客户配置。在那里您可以找到创建新帐户选项。

    对于我所看到的客户组,核心 Magento 只允许在同一配置组中为每个 storeview 配置该选项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-16
      • 2014-02-10
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-22
      相关资源
      最近更新 更多