Magento "Forgot Password" email sent in the wrong language

I have a Magento website with several languages. I installed language packs and everything seems to translate correctly to the website. In addition, transactional emails are sent in the correct language, EXCEPT for " Forgot Password ", which is always sent in German. Here is what I did:

  • Installed language packs and make sure that all templates and folder structures are correct. Example: /app/locale/nl_NL/template/email/
  • In System> Transactional Letters . I applied the template, selected the locale and saved.
  • Then I went to the Sales Emails Configuration System , I switched to each language from the Current Configuration Scope drop-down list, and I selected the templates that I created in Transactional Emails for each language (each store).

After viewing the solution on the Internet, others seemed to have this problem, and someone mentioned that Magento selects the Forgot Password template from the first locale folder found in / app / locale /. In my case, I had: de_DE , en_US , fr_FR , nl_NL . Therefore, he selects a template from the German package de_DE .

NOTE In addition, in the backend in the “Configuration” section there is a tab on the left called “LOCALE PACKS”, in which there is only “Locale de_DE”, although I have other language packs that do not appear here. Not sure if this is relevant.

Website: http://site1.cp1.glimworm.com/magento/

Magento Community Version: 1.7.0.2

Local packages:

  • Mage_Locale_en_US
  • Locale_Mage_community_de_DE
  • Locale_Mage_community_fr_FR
  • Mage_Locale_nl_NL

Any idea how I can get the correct email template from the appropriate language for sending, and not always German? Any help would be greatly appreciated! I can also provide additional information.

+4
source share
8 answers

I have the same problem in magento v1.5. After a long research, I found this solution and its work for me.

 Mage/Customer/Model/Customer.php in this file i have make some changes as following. find this line of code if (!$storeId) { $storeId = $this->_getWebsiteStoreId($this->getSendemailStoreId()); } and replace with $storeId = ($storeId == '0')?$this->getSendemailStoreId():$storeId; if ($this->getWebsiteId() != '0' && $storeId == '0') { $storeIds = Mage::app()->getWebsite($this->getWebsiteId())->getStoreIds(); reset($storeIds); $storeId = current($storeIds); } 
+5
source

I had the same problem and it looks like the solution user2282917 works with a little change:

You should edit the sendPasswordResetConfirmationEmail function in Customer.php, not sendNewAccountEmail. Try replacing the code there and it will work.

+3
source

Overwrite the forgotten password controller PostAction on AccountController.php. You need to set the correct store identifier for it to be used.

 /** * Forgot customer password action */ public function forgotPasswordPostAction() { $email = (string) $this->getRequest()->getPost('email'); if ($email) { if (!Zend_Validate::is($email, 'EmailAddress')) { $this->_getSession()->setForgottenEmail($email); $this->_getSession()->addError($this->__('Invalid email address.')); $this->_redirect('*/*/forgotpassword'); return; } /** @var $customer Mage_Customer_Model_Customer */ $customer = $this->_getModel('customer/customer') ->setWebsiteId(Mage::app()->getStore()->getWebsiteId()) ->loadByEmail($email); if ($customer->getId()) { try { $newResetPasswordLinkToken = $this->_getHelper('customer')->generateResetPasswordLinkToken(); $customer->changeResetPasswordLinkToken($newResetPasswordLinkToken); // Add store ID so that correct locale will be set $customer->setStoreId(Mage::app()->getStore()->getId()); $customer->sendPasswordResetConfirmationEmail(); } catch (Exception $exception) { $this->_getSession()->addError($exception->getMessage()); $this->_redirect('*/*/forgotpassword'); return; } } $this->_getSession() ->addSuccess( $this->_getHelper('customer') ->__('If there is an account associated with %s you will receive an email with a link to reset your password.', $this->_getHelper('customer')->escapeHtml($email))); $this->_redirect('*/*/'); return; } else { $this->_getSession()->addError($this->__('Please enter your email.')); $this->_redirect('*/*/forgotpassword'); return; } } 
+1
source

In the following file, Mage / Client / Model / Customer.php

In the sendPasswordResetConfirmationEmail () function, change

$ storeId = $ this-> getStoreId ();

to

$ storeId = Mage :: app () → getStore () → getStoreId ();

thanks

+1
source

In our case ... We found that when the client account was created by the administrator, the "send by email" option was not saved and was used only for e-mail to create the first account. Any subsequent sent messages are sent from the default repository view on the website to which the client has been allocated.

The real problem is how when a customer’s store identifier is identified when none are installed.

The sendPasswordResetConfirmationEmail method (Magento 1.9.1), when the store ID is 0 (admin or not set), the default is _getWebsiteStoreId, which will return the first store ID associated with this site.

The problem is that Magento assumes that the first store identifier associated with the site identifier is the default store ... We found that this is not the case when the sort order is set against the store record.

Simply put, make sure your default directory associated with the website is also listed with a sort order of 0.

+1
source

Hope this link will be useful to you

In the link they used the New password, but instead of the new password Use the forgotten password template. At step 4

Thanks..

0
source

The reset password is sent to Mage_Customer_Model_Customer::_sendEmailTemplate() . Email is uploaded here. If it was loaded by the administrator in "Systemn> Transactional Emails" and configured to use, your template will be used.

Otherwise, the template is loaded by default from the file into Mage_Core_Model_Email_Template::sendTransactional . This is done using $this->loadDefault($templateId, $localeCode); . Ist template uploaded using

 $templateText = Mage::app()->getTranslator()->getTemplateFile( $data['file'], 'email', $locale ); 

Here, the locale folders are checked in the following order:

  • Specified language
  • Default Storage Language
  • ru_US locale

The first consistent language is selected. Since Mage::app() does not know about the store that was transferred using the emailtemplate template, the defaultstore default file is downloaded, which is German in your case. This has nothing to do with the order of the locale directories.

So, in your case, I suggest checking if your email template is selected in the administrator’s configuration under "System> Config> Customerconfiguration> Options Options" or use Mage::getStoreConfig(Mage_Customer_Model_Customer::XML_PATH_REMIND_EMAIL_TEMPLATE, $storeId) , if set for your storage facilities.

0
source

The reason why you receive email templates in a language other than expected depends on the language in which you first created your account. Try to verify this in your own language when you first created your account.

In the Clients> Account Information section, check how your account was created.

/Caliph

0
source

Source: https://habr.com/ru/post/1489049/


All Articles