Magento:为客户定制登录失败消息?

时间:2014-11-28 09:20:56

标签: php magento

Login failed

我有一个magento网站,如果用户的电子邮件和密码无效,则会显示此消息。

我想要的是该邮件的输出反映哪个凭据错误。例如'错误的密码'或'错误的电子邮件地址'。

这可能吗?

1 个答案:

答案 0 :(得分:2)

登录操作网址为http://domain.com/index.php/customer/account/loginPost/

如果您在app/code/core/Mage/Customer/controllers/ loginpostAction()

查看switch ($e->getCode()) { case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED: $value = $this->_getHelper('customer')->getEmailConfirmationUrl($login['username']); $message = $this->_getHelper('customer')->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.', $value); break; case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD: $message = $e->getMessage(); break; default: $message = $e->getMessage(); } 中的Accountcontroller.php文件

Magento尝试从常量

加载错误消息
Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:

此处 public function authenticate($login, $password) { $this->loadByEmail($login); if ($this->getConfirmation() && $this->isConfirmationRequired()) { throw Mage::exception('Mage_Core', Mage::helper('customer')->__('This account is not confirmed.'), self::EXCEPTION_EMAIL_NOT_CONFIRMED ); } if (!$this->validatePassword($password)) { throw Mage::exception('Mage_Core', Mage::helper('customer')->__('Invalid login or password.'), self::EXCEPTION_INVALID_EMAIL_OR_PASSWORD ); } Mage::dispatchEvent('customer_customer_authenticated', array( 'model' => $this, 'password' => $password, )); return true; } 从中加载该消息  法/客户/型号/ Customer.php

{{1}}

在这里你可以看到那条消息。但触摸核心文件并不是一个好主意。但您可以通过重写核心模块来实现这一目标。

相关问题