Magento客户登录通知电子邮件已发送给客户

时间:2017-02-08 07:32:18

标签: email magento templates

是否有一个简单的解决方案让客户每次登录商店时都会收到通知电子邮件?

我正在创建扩展程序

app / etc / Module Custom_Notify.xml

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

app / code / local / Custom / Notify / etc config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Custom_Notify>
      <version>0.1.0</version>
    </Custom_Notify>
  </modules>
  <frontend>
    <events>
    <customer_login>
        <observers>
            <cnotify>
                <type>model</type>
                <class>cnotify/observer</class>
                <method>customerNotify</method>
            </cnotify>
        </observers>
    </customer_login>
    </events>
  </frontend>
  <global>
    <helpers>
      <cnotify>
        <class>Custom_Notify_Helper</class>
      </cnotify>
    </helpers>
    <blocks>
      <cnotify>
        <class>Custom_Notify_Block</class>
      </cnotify>
    </blocks>
    <models>
      <cnotify>
        <class>Custom_Notify_Model</class>
      </cnotify>
    </models>  
  </global>
</config>

应用程序/代码/本地/客户/通知/型号/的 Observer.php

<?php

class Custom_Notify_Model_Observer {

  public function customerNotify($observer) {

    /* for  Template  */
    $template_id= '1';

     $customer = Mage::getSingleton('customer/session')->getCustomer();

    $recepient = array(
        'name' => $customer->getName(),
        'email' => $customer->getEmail()
    );


    $sender = array(
        'name' => Mage::getStoreConfig('trans_email/ident_general/name'),
        'email' => Mage::getStoreConfig('trans_email/ident_general/email')
    );

    $email_template_variables = array(
        'customer_name' => $customer->getName(),
        'customer_email' =>  $customer->getEmail()

    );

    $email_template  = Mage::getModel('core/email_template')->loadDefault($template_id);
    $storeId = Mage::app()->getStore()->getId();

    $email_template->setSenderName($sender['name']);
    $email_template->setSenderEmail($sender['email']);
    $email_template->send($recepient['email'], $recepient['name'], $email_template_variables,$storeId);


    }

}

0 个答案:

没有答案