1

我想停止在 magento 1.7.0.2 中向客户发送欢迎电子邮件。请尽快让我知道任何解决方案。提前致谢。

4

1 回答 1

8

不幸的是,这不是一项简单的任务,并且无法通过 Magento Admin 来完成。

有几个地方可以启动此欢迎电子邮件,但您可以在客户模型级别停止它。完成这项工作的函数是 Mage_Customer_Model_Customer::sendNewAccountEmail(app/code/core/Mage/Customer/Model/Customer.php 第 587 行)

您将需要创建一个具有配置设置的新模块以禁用电子邮件,然后扩展客户模型方法,读取设置。

像这样的东西(未经测试的代码,使用风险自负):

在您的模块的 system.xml 中:

<sections>
        <customer>
            <groups>
                <create_account>
                    <send_welcome_email translate="label">
                        <label>Send Welcome Email?</label>
                        <frontend_type>select</frontend_type>
                        <source_model>adminhtml/system_config_source_yesno</source_model>
                        <sort_order>65</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                    </auto_group_assign>                    
                </send_welcome_email>                   
            </groups>
        </customer>
</sections>

扩展客户模型。在您的模块中,Model/Customer.php

class YourModule_Model_Customer extends Mage_Customer_Model_Customer
{   
    public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
    {   
        if ( ! Mage::getStoreConfig('customer/create_account/send_welcome_email') ) {
            return $this;
        }

        $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;
    }
}
于 2014-01-28T15:52:00.050 回答