2013-07-01 48 views
4

我有一個帶有多種語言的Magento網站。我已經設置了語言包,並且所有內容似乎都可以在網站上正確翻譯。除了「忘記密碼」電子郵件總是以德文發送外,交易電子郵件也以正確語言發送。以下是我所做的:Magento以錯誤的語言發送「忘記密碼」電子郵件

  • 已安裝的語言包並確保所有模板和文件夾結構都正確。例如:/app/locale/nl_NL/template/email/
  • 系統»交易電子郵件:我應用了模板,選擇了區域並保存。
  • 然後我去系統»配置»銷售電子郵件,我切換到從‘當前配置範圍’下拉列表中的每種語言,我選擇了我的交易電子郵件創建的模板爲每種語言(每家店視圖) 。

網上四處尋找一個解決方案後,似乎其他人也有這個問題,有人提到,Magento的是採摘的「忘記密碼」從/應用/區域/發現第一現場的文件夾模板。在我的情況下,我有:de_DE,en_US,fr_FR,nl_NL。所以它從德文de_DE包中挑選模板。

注意:此外,在「配置」下的後端有一個名爲「LOCALE包」,只有具有「區域設置de_DE這個」下,它在左側的選項卡,即使我有其他語言包不顯示上面這兒。不確定這是否相關。

網站:http://site1.cp1.glimworm.com/magento/

Magento的社區版本:1.7.0.2

區域設置包:

  • Mage_Locale_en_US
  • Locale_Mage_community_de_DE
  • Locale_Mage_community_fr_FR
  • Mage_Locale_nl_NL

任何想法如何從相應的語言得到正確的電子郵件模板發送,而不是總是德國?任何幫助將不勝感激!我可以提供更多信息。

+0

沒有人有解決方案嗎? :( – Glimworm

回答

0

希望this link將是有用的,以你

在聯繫他們使用新密碼,而是新密碼的使用忘記密碼模板在步驟4

謝謝..

+0

感謝您的信息!我確實嘗試了這個,實際上我已經有了和他們在示例中使用的模板相同的模板,但是我實際上試圖使用另一個模板,但它沒有區別。郵件 – Glimworm

5

我有同樣的問題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); 
} 
+0

感謝你!雖然它不適合我,但現在只是嘗試過,但同樣的事情發生:所有「忘記密碼」郵件用德語發送:( 但我也使用v1.7所以也許有一個區別? – Glimworm

3

我有同樣的問題,它看起來像user2282917的解決方案可與一點點修改:

你應該在Customer.php不是sendNewAccountEmail編輯sendPasswordResetConfirmationEmail功能。嘗試替換那裏的代碼,它會工作。

0

密碼重置郵件發送Mage_Customer_Model_Customer::_sendEmailTemplate()。這裏加載了emailtemplate。如果它是在「Systemn>交易電子郵件」中的管理員中加載並配置爲使用,則將使用您的模板。

否則從Mage_Core_Model_Email_Template::sendTransactional中的文件加載默認模板。這是使用$this->loadDefault($templateId, $localeCode);使用

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

這裏的語言環境文件夾中的模板北京時間加載做過如下順序檢查:

  1. 指定的語言環境
  2. 區域設置默認存儲
  3. en_US環境

選擇第一個匹配的區域設置。由於Mage::app()不知道使用電子郵件模板傳遞的商店,因此默認的默認存儲會被加載,在您的情況下是德語。它與locale文件夾的順序無關。

因此,在您的情況下,我建議檢查您的電子郵件模板是否在管理配置中的「系統>配置>客戶配置>密碼選項」中選擇,或者如果您的商店設置爲Mage::getStoreConfig(Mage_Customer_Model_Customer::XML_PATH_REMIND_EMAIL_TEMPLATE, $storeId)

1

覆蓋AccountController.php中的forgotPasswordPostAction控制器。 您需要設置正確的商店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; 
    } 
} 
1

在下面的文件 法/客戶/型號/ Customer.php

在sendPasswordResetConfirmationEmail函數()改變

$ STOREID = $這 - > getStoreId();

$ STOREID =法師::應用程序() - > getStore() - > getStoreId();

感謝

0

原因爲何會收到電子郵件模板中另一種語言不是一個預期的是依賴於你第一次創建帳戶的語言。當您第一次創建帳戶時,請嘗試使用您自己的語言進行檢查。

請在Customers> Account Information下查看,瞭解您的帳戶是如何創建的。

/Kalif

1

在我們的案例中...我們發現,當管理員創建客戶帳戶時,「發送電子郵件」選項未保存,僅用於第一個帳戶創建電子郵件。任何後續發送的電子郵件都是從客戶分配的網站的默認商店視圖發送的。

真正的問題是如何識別客戶商店標識時沒有設置。

方法sendPasswordResetConfirmationEmail(Magento的1.9.1)當商店ID爲0(admin或不設置),默認爲_getWebsiteStoreId將返回關聯到該網站的第一商店編號。

問題是,Magento認爲與網站ID相關聯的第一個商店ID是默認商店...我們發現,當對商店記錄設置排序順序時,情況並非如此。

簡單地說,請確保您的默認商店與一個網站相關聯,也指定排序順序爲0.

相關問題