2014-01-22 25 views
2

我要重寫在前端網站的Magento的忘記密碼消息:如何替代忘記密碼的提示,在Magento

  1. 當我在前臺網站點擊忘記密碼,它說:

如果有一個帳戶與[email protected]相關聯,您將收到一封電子郵件,其中包含重置密碼的鏈接。

我要覆蓋此消息的電子郵件驗證:

  1. 您的電子郵件地址[email protected]不存在,或
  2. 我們已經給你發一個重置鏈接你的電子郵件地址[email protected]

我有Magento默認消息中的替代解決方案與驗證嗎?

感謝,

回答

3

你可以找到這在

Mage_Customer_AccountController 

和去功能forgotPasswordPostAction()

以及與此代碼替換 **

你的病情入手//自定義代碼開始 **

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 = Mage::getModel('customer/customer') 
       ->setWebsiteId(Mage::app()->getStore()->getWebsiteId()) 
       ->loadByEmail($email); 

      if ($customer->getId()) { 
       try { 
        $newResetPasswordLinkToken = Mage::helper('customer')->generateResetPasswordLinkToken(); 
        $customer->changeResetPasswordLinkToken($newResetPasswordLinkToken); 
        $customer->sendPasswordResetConfirmationEmail(); 
       } catch (Exception $exception) { 
        $this->_getSession()->addError($exception->getMessage()); 
        $this->_redirect('*/*/forgotpassword'); 
        return; 
       } 
      } 
      else //custom code start 
      { 
       $this->_getSession()->addError(Mage::helper('customer')->__('Your email address %s does not exist.',Mage::helper('customer')->htmlEscape($email))); 
      $this->_redirect('*/*/'); 
      return; 
      }//custom code end 
      $this->_getSession() 
       ->addSuccess(Mage::helper('customer')->__('We have sent you a reset link in your email address %s .', Mage::helper('customer')->htmlEscape($email))); 
      $this->_redirect('*/*/'); 
      return; 
     } else { 
      $this->_getSession()->addError($this->__('Please enter your email.')); 
      $this->_redirect('*/*/forgotpassword'); 
      return; 
     } 
    } 

後你可以覆蓋這個

+0

好的。謝謝,等等。我會檢查它。 :) –

+1

非常感謝!這是一個很大的幫助。代碼現在正在工作。標記爲答案! –

+0

完成。再次感謝! –

0

轉到下面的類

Mage_Customer_AccountController 

這個函數內部此消息存在

forgotPasswordPostAction() 

你可以從上面的類中重寫此功能

+0

謝謝,那麼我該如何從magento中獲取電子郵件地址。請檢查代碼。謝謝, –

+0

這個變量$ email包含email-id,你可以用它 –

+0

好的。謝謝,我會檢查它! :) –