Magento“;“忘记密码”;以错误语言发送的电子邮件
我有一个多语言的Magento网站。我已经设置了语言包,网站上的所有内容似乎都翻译正确。除“忘记密码”“电子邮件始终以德语发送外,事务性电子邮件也以正确的语言发送。以下是我所做的:Magento“;“忘记密码”;以错误语言发送的电子邮件,magento,email,magento-1.7,multilingual,forgot-password,Magento,Email,Magento 1.7,Multilingual,Forgot Password,我有一个多语言的Magento网站。我已经设置了语言包,网站上的所有内容似乎都翻译正确。除“忘记密码”“电子邮件始终以德语发送外,事务性电子邮件也以正确的语言发送。以下是我所做的: 已安装语言包,并确保所有模板和文件夹结构正确。示例:/app/locale/nl\u nl/template/email/ 在系统»事务性电子邮件下:我应用了模板,选择了区域设置并保存 然后我转到系统»配置»销售电子邮件,从“当前配置范围”下拉列表切换到每种语言,并为每种语言(每个商店视图)选择在事务性电子邮件中创
- 已安装语言包,并确保所有模板和文件夹结构正确。示例:
/app/locale/nl\u nl/template/email/
- 在系统»事务性电子邮件下:我应用了模板,选择了区域设置并保存
- 然后我转到系统»配置»销售电子邮件,从“当前配置范围”下拉列表切换到每种语言,并为每种语言(每个商店视图)选择在事务性电子邮件中创建的模板
de_de
,en_US
,fr_fr
,nl_nl
。因此,它从德语de_de
pack中选择模板
注意:此外,在后端的“配置”下,左侧有一个名为“语言环境包”的选项卡,该选项卡下只有“语言环境包”,尽管我有其他语言包,但这里没有显示。不确定这是否相关
地点:
Magento社区版本:1.7.0.2
区域设置包:
- 魔术师现场
- 地点(图像)(社区)(社区)
- 区域设置\u图像\u社区\u fr\u fr
- 魔术师地点
谢谢..我在magento v1.5中遇到了同样的问题。经过长时间的研究,我发现了这个解决方案,而且它对我很有效
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);
}
我也遇到了同样的问题,看起来user2282917的解决方案需要稍加修改:
您应该编辑Customer.php中的sendpasswordresetconfirmationmail函数,而不是sendNewAccountEmail。尝试在那里替换代码,它就会工作。密码重置电子邮件将发送到
Mage\u Customer\u Model\u Customer::\u sendmailtemplate()
。这里加载了emailtemplate。如果它被加载到“Systemn>事务性电子邮件”的管理中并配置为使用,则将使用您的模板
/**
* 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;
}
}
否则,默认模板将从Mage\u Core\u Model\u Email\u template::sendTransactional
中的文件加载。这是使用$This->loadDefault($templateId,$localeCode)完成的代码>使用加载模板
$templateText = Mage::app()->getTranslator()->getTemplateFile(
$data['file'], 'email', $locale
);
此处按以下顺序检查区域设置文件夹:
指定区域设置
默认存储的区域设置
恩努斯地区
选择第一个匹配的区域设置。由于Mage::app()
不知道随emailtemplate一起传递的存储,因此会加载默认的defaultstore,在您的示例中是德语。这与区域设置文件夹的顺序无关
因此,在您的情况下,我建议检查您的emailtemplate是否在“系统>配置>客户配置>密码选项”的管理配置中被选中,或者使用Mage::getStoreConfig(Mage\u客户\模型\客户::XML\u路径\提醒\电子邮件\模板,$storeId)
如果它是为您的商店设置的。覆盖AccountController.php上的前述PasswordPostAction控制器。
您需要设置正确的存储id,以便使用区域设置
/**
* 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;
}
}
在下面的文件中
Mage/Customer/Model/Customer.php
在SendPasswordResetConfirmationMail函数()中,更改
$storeId=$this->getStoreId()
到
$storeId=Mage::app()->getStore()->getStoreId()
谢谢您收到电子邮件模板时使用的语言与预期语言不同的原因取决于您最初创建帐户时使用的语言。当您第一次创建帐户时,请尝试使用您自己的语言进行检查
在客户>帐户信息下选中此项,查看您的帐户是如何创建的
/卡利夫在我们的案例中。。。我们发现,当管理员创建客户帐户时,“email send from”选项未保存,仅用于第一封帐户创建电子邮件。任何后续发送的电子邮件都是从客户分配的网站的默认商店视图发送的
真正的问题是,当没有设置客户商店id时,如何识别客户商店id
当存储id为0(管理或未设置)时,方法sendpasswordresetconfirmationmail(Magento 1.9.1)默认为_getWebsiteStoreId,它将返回与该网站关联的第一个存储id
问题是Magento假定与网站id关联的第一个存储id是默认存储。。。我们发现,当针对存储记录设置排序顺序时,情况并非如此
简单地说,请确保您与网站关联的默认存储也指定为排序顺序为0。谢谢!虽然它对我不起作用。刚刚尝试过,但同样的事情发生了:所有“忘记密码”邮件都用德语发送:(但我也在使用v1.7,所以可能会有不同?谢谢你提供的信息!我确实尝试了这个,实际上我已经有了他们在示例中使用的相同模板。但后来我实际上尝试一起使用另一个模板,但没有什么不同。我在邮件中收到了相同的德语模板。没有人有解决方案?:(