1

How to send separate Email template (customer_password_forgot_email_template) when

user Group id=4 using module extend Mage_Customer_Model_Customer.

class Creative_Login_Model_Customer extends Mage_Customer_Model_Customer
{
    public function sendPasswordResetConfirmationEmail()
    {
        if (!$storeId) {
            $storeId = $this->_getWebsiteStoreId();
        }

        $this->_sendEmailTemplate(self::XML_PATH_FORGOT_EMAIL_TEMPLATE, self::XML_PATH_FORGOT_EMAIL_IDENTITY,
            array('customer' => $this), $storeId);
        return $this;
    }

}

This code working but i want separate mail template for only groupid= 4.

config.xml

<?xml version="1.0"?>
<config>
   <modules>
     <Creative_Login>
         <version>0.0.1</version>
     </Creative_Login>
   </modules>
   <!-- After login hook -->
   <global>
      <models>
        <creative_login>
           <class>Creative_Login_Model</class>
        </creative_login>
        <customer>
            <rewrite>
                <customer>Creative_Login_Model_Customer</customer>
            </rewrite>
        </customer>
      </models>
      <template>
            <email>
                <customer_password_forgot_email_template translate="label" module="creative_login">
                    <label>Forgot Password</label>
                    <file>account_password_reset_confirmation_creative_login.html</file>
                    <type>html</type>
                </customer_password_forgot_email_template>
            </email>
      </template>
   </global>
   <!-- ##################### -->

   <frontend>
       <!-- ########After login hook######### -->
      <events>
         <customer_login>
           <observers>
              <creative_customer_login>
                 <class>creative_login/observer</class>
                 <method>checkLoginStatus</method>             
              </creative_customer_login>
           </observers>
         </customer_login>
      </events>
       <!-- ##################### -->
       <!-- Before login hook -->
        <routers>
            <customer>
                <args>
                    <modules>
                        <creative_login before="Mage_Customer">Creative_Login</creative_login>
                    </modules>
                </args>
            </customer>
        </routers>
   </frontend>
</config>

1 Answer 1

0

ravi.As you reweite customer class Mage_Customer_Model_Customer and then $this give customer object

in this function you can get customer if by using below code :

  $this->getGroupId()

also you need create an customer forgort pasword rest password email html template and define it config.xml

Step1: add new customer forgot password confirmation mail template for this customer group using

below code at config.xml



<template>
        <email>
            <customer_password_forgot_email_template_groupnew translate="label" module="customer">
                <label>Forgot Password</label>
                <file>account_password_reset_confirmation_new.html</file>
                <type>html</type>
            </customer_password_forgot_email_template_groupnew>
        </email>
    </template>

by this code i have add new email template and template code is customer_password_forgot_email_template_groupnew

Step2: for getting this email template add below code at outside in config.xml

<default>
    <customer>
      <password>
                <forgot_email_template_newgroup>customer_password_forgot_email_template_groupnew</forgot_email_template_newgroup>
      </password>
    </customer>
</default>

Step3: you need to call this template at sendPasswordResetConfirmationEmail of rewrite function

if($this->getGroupId()==4) <!-- check your group id -->
     $this->_sendEmailTemplate('customer/password/forgot_email_template_newgroup', self::XML_PATH_FORGOT_EMAIL_IDENTITY,
            array('customer' => $this), $storeId);
      }
      else{
         $this->_sendEmailTemplate(self::XML_PATH_FORGOT_EMAIL_TEMPLATE, self::XML_PATH_FORGOT_EMAIL_IDENTITY,
            array('customer' => $this), $storeId);
      }

Step4: you to create new html name as account_password_reset_confirmation_new.html at app/locale/yourlanguage/template/email

Hope it will help you.

3
  • Thanks, but how to set condition for only group 4 see my congif.xml at this all user same template access. Sep 18, 2014 at 7:39
  • wait give you solution
    – Amit Bera
    Sep 18, 2014 at 7:41
  • hi W_Onestepcheckout how to override. class AW_Onestepcheckout_AjaxController extends Mage_Checkout_Controller_Action Sep 22, 2014 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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