5

I have two shop views and both use the same user accounts. If an user registers to shop A and requests a password reset in shop B, he gets a link to shop A.

In the email template this link is created with:

{{store url="customer/account/resetpassword/" _query_id=$customer.id _query_token=$customer.rp_token}}

I would like the email to link to the shop it is send from.

1 Answer 1

5

What I think happens is that in the email send function Mage_Customer_Model_Customer::sendPasswordResetConfirmationEmail the store id attached to the loaded user is used and not the current store you are on.

public function sendPasswordResetConfirmationEmail()
{
    $storeId = $this->getStoreId();
    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;
}

If the customer has been created via the admin the store id here will be the current websites' default store id.

What you would need to do is change this function to use the current store id rather than the one attached to the user, but I am sure this was done for a purpose though I do not know what that is.

The "simplest" way of doing this would be to change the line $storeId = $this->getStoreId(); to be $storeId = Mage::app()->getStore()->getId();

Note: This happens across a lot of the emails that are sent to the customer

5
  • I just found this function myself and this did work (added my fix). I will keep an eye on possible side effects and report back if I find any... Oct 7, 2014 at 15:43
  • cool, there are more functions in the Mage_Customer_Model_Customer that do this sort of thing Oct 7, 2014 at 15:45
  • Is this really the problem? If the user exists two times it looks to me like Magento finds the wrong user for the password request function?
    – Alex
    Oct 7, 2014 at 15:49
  • @DavidManners good point! The same happens in sendNewAccountEmail() and sendPasswordReminderEmail(). But the first is always in the correct shop and the other one is not used in my case. So I think this is fine. Oct 7, 2014 at 15:54
  • @Alex I am not really sure why this is done this way but the email address is unique on website level. I guess it is done to send the email to the user in the language/store they are registered against Oct 7, 2014 at 15:54

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.