0

I apologize in advance for this question has been treated many times, but I think I just need a personal trainer on this!

I am trying to modify the function sendPasswordResetConfirmationEmail in Mage/Customer/Model/Customer.php

 public function sendPasswordResetConfirmationEmail()
    {
        $storeId = $this->getStoreId(); // ---->this is the line I need to change----<
        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;
    }

So I created a module called M2W_Password in local, it contains etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <M2W_Password>
            <version>0.1.0</version>
        </M2W_Password>
    </modules>
    <global>
        <models>
            <customer>
                <rewrite>
                    <customer>M2W_Password_Model_Customer_Customer</customer>
                </rewrite>
            </customer>
        </models>
    </global>
</config>

And here is the updated function in Model/Customer/Customer.php

<?php

class M2W_Password_Model_Customer_Customer extends Mage_Customer_Model_Customer
{

    public function sendPasswordResetConfirmationEmail()
    {
        $storeId = Mage::app()->getStore()->getId();
        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;
    }

}

?>

I cleared the cache, checked that the module is in Magento list of modules in system/configuration/Advanced, but the fix I put in my function is still not working.

EDIT --------------------------------

I just found out that another module extends the MAge_Customer_Model_Customer class. So here is my new class for Customer.php

class M2W_Password_Model_Customer_Customer extends Magestore_Onestepcheckout_Model_Customer_Customer {

But still it doesn't work. Which is weird because when I put the actual code I'm trying to implement directly in the other module Customer.php it works

4
  • By the way, my fix works when I modify the core function directly
    – Antho Ny
    Sep 11, 2015 at 21:07
  • Have you create M2W_Password.xml to app/etc/modules?
    – Amit Bera
    Sep 12, 2015 at 7:11
  • need to check compiler enable or not? also require to check any module rewrite thar class
    – Amit Bera
    Sep 12, 2015 at 7:16
  • Thanks guys, I forgot to mention that I had my module declared in app/etc/modules. So no success on that front. @AmitBera what do you mean exactly?
    – Antho Ny
    Sep 14, 2015 at 14:45

3 Answers 3

0

Update your config.xml <models> <password> <class>M2W_Password_Model</class> <resourceModel>password_mysql4</resourceModel> </password> <customer> <rewrite> <customer>M2W_Password_Model_Customer_Customer</customer> </rewrite> </customer> </models>

2
  • Thanks HarryP, AddWeb Solution Pvt Ltd offered the same solution, but it doesn't change anything. Why do you guys add the password tag?
    – Antho Ny
    Sep 14, 2015 at 14:49
  • Password tag specifies the model namespace. Sep 15, 2015 at 11:07
0

To create custom module follow the below steps:

Step 1:- app\etc\module\M2W_Password.xml

<?xml version="1.0"?>
<config>
<modules>
<M2W_Password>
  <active>true</active>
    <codePool>local</codePool>
  <version>0.1.0</version>
</M2W_Password>
</modules>
</config>

Step 2:- app\code\local\M2W\Password\etc\config.xml

<?xml version="1.0"?>
<config>
<modules>
<M2W_Password>
  <version>0.1.0</version>
</M2W_Password>
</modules>
<global>
    <models>
      <password>
            <class>M2W_Password_Model</class>
            <resourceModel>password_mysql4</resourceModel>
      </password>
            <customer>
                <rewrite>
                    <customer>M2W_Password_Model_Customer_Customer</customer>
                </rewrite>
            </customer>
    </models>
</global>

Step 3:- app\code\local\M2W\Password\Model\Customer\Customer.php

 <?php
 class M2W_Password_Model_Customer_Customer extends Mage_Customer_Model_Customer
 {
    public function sendPasswordResetConfirmationEmail()
    {
            //echo "Come Here"; 
            //exit; 
            $storeId = Mage::app()->getStore()->getId();
            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;
    } 
 }

Please clear cache and check frontend.

3
  • Thanks @AddWeb Solution Pvt Ltd but it still doesn't work, when I uncomment echo "come here" I don't get anything. Any idea?
    – Antho Ny
    Sep 14, 2015 at 14:47
  • @AnthoNy If you have followed proper folder structure (as we have provided) then this issue should be resolved, as we have tried on local. Sep 15, 2015 at 7:31
  • Hi, It has worked but the module created was conflicting with another one that we use. If you check my question you'll see that I edited it and I also provided an answer. Thanks for your help!
    – Antho Ny
    Sep 15, 2015 at 21:28
0

So I found out how to resolve the clash.

here is Customer.php

<?php
 class M2W_Password_Model_Customer_Customer extends Mage_Customer_Model_Customer
 {
    public function sendPasswordResetConfirmationEmail()
    {

            $storeId = Mage::app()->getStore()->getId();
            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;
    } 
 }

And I modified the class in the other module with them calling my class

class Magestore_Onestepcheckout_Model_Customer_Customer extends M2W_Password_Model_Customer_Customer
{  

I then commented out the rewrite tag of my module M2W/Password/etc/config.xml

    <models>
            <customer>
                <!-- <rewrite>
                    <customer>M2W_Password_Model_Customer_Customer</customer>
                </rewrite> -->
            </customer>
    </models>

Your Answer

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

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