如何在magento 1.7.0.2中停止向客户发送欢迎电子邮件

时间:2013-06-08 06:13:17

标签: magento-1.7

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

1 个答案:

答案 0 :(得分:8)

不幸的是,这不是一项简单的任务,也无法通过Magento Admin进行。

这个受欢迎的电子邮件可以从一些地方开始,但您可以在客户模型级别停止它。完成工作的功能是Mage_Customer_Model_Customer :: sendNewAccountEmail(app / code / core / Mage / Customer / Model / Customer.php 587行)

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

这样的事情(未经测试的代码,使用风险自负):

在Module的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>

扩展客户模型。在您的Module,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;
    }
}