0

Is there an easy solution for the customer to receive a notification email every time login to the store?

i am creating extension

Custom_Notify.xml

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

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);


    }

}
  • you need to add custom code for this. there is no functionality in magento for this requirement. – BornCoder Feb 8 '17 at 5:35
  • yes i know it very well bro ...but how can you tell me – Sarvesh Tiwari Feb 8 '17 at 5:36
2

Here is your config.xml for module

<?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>

here is Observer.php

<?php

class Custom_Notify_Model_Observer {

  public function customerNotify($observer) {

    /* for  Template  */
    $template_id= 'put Template id which is created in admin transaction email';

     $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);


    }

}

i wish i would helpful

  • sorry i did not get you. can you explain it please – Sarvesh Tiwari Feb 8 '17 at 5:48
  • do you have any custom module in local code pool ? – Dharmesh Feb 8 '17 at 5:50
  • yes i have ...i am writing your code on app/code/core/mage/customer/config.xml – Sarvesh Tiwari Feb 8 '17 at 5:52
  • no no, don not use inbuilt module for this make new module, i'll send you code , wait – Dharmesh Feb 8 '17 at 5:54
  • bro its not working for me can you check my updated question – Sarvesh Tiwari Feb 8 '17 at 6:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.