2016-04-12 15 views
0

Bir magento mağazasında özel bir e-posta gönderiyorum. İyi bir işlem şablonu kullanıyor. Sorun şu ki, bu magento, bu özel e-posta için iso-8859-1 kodlamasını kullanmaktadır, default_encoding = 'utf-8' indeksini Mage/Page/etc/config.xmlMagento e-posta modelini maalesef kodlayan iso-8859-1

'dan aramak için denedim. Kodlamayı doğrudan ayarlamak için bir işlev ancak bir tane bulamadı. Bu problemle karşılaşan ve çözen var mı? Hızlı bir düzeltme için ihtiyacım var. Magento'nun işlemsel posta sistemini daha iyi kullanmam gerektiğini biliyorum, ancak sistemde büyük değişiklikler yapamıyoruz, çünkü sadece çevrimiçi oldu ve henüz bir devasa ortamımız yok.

zaman kodu:

public function customerSaveBefore($observer) { 
    $customer = $observer->getCustomer(); 

    //Array of customer data 
    $customerData = $customer->getData(); 

    //email address from System > Configuration > Contacts 
    $contactEmail = Mage::getStoreConfig('contacts/email/recipient_email'); 

    //customer is new, otherwise it's an edit 
    if (!$customer->getOrigData()) { 


     $session = Mage::getSingleton('core/session', array('name'=>'frontend')); 
     $addressData = $session->getCustomerAddress(); //get customers address from session variable 

     $emailTemplate = Mage::getModel("core/email_template") 
      ->loadDefault("customer_notification"); 

     $emailTemplateVariables = array(); 
     $emailTemplateVariables["customer"] = $customer; 
     $emailTemplateVariables["plz"] = $addressData['postcode']; 
     $emailTemplateVariables["city"] = $addressData['city']; 
     $emailTemplateVariables["company"] = $addressData['company']; 
     $emailTemplateVariables["street"] = $addressData['street'][0]; 
     $emailTemplateVariables["phone"] = $addressData['telephone']; 
     $emailTemplateVariables["erpid"] = $session->getCustomerUserId(); 

     $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables); 

     $mail = Mage::getModel("core/email") 
     ->setToEmail("[email protected]") 
     ->setBody($processedTemplate) 
     ->setFromEmail($sender) 
     ->setFromName("EMAIL") 
     ->setSubject("Subject") 
     ->setType("html"); 

     try{ 
      $mail->send(); 
     } 
     catch(Exception $error) 
     { 
      Mage::getSingleton("core/session")->addError($error->getMessage()); 
      return false; 
     } 
     $mail->setToEmail($recipient) 
      ->setFromEmail($recipient); 
     try{ 

     $session->setCustomerAddress([]); //clear customers address in session variable 
    } 

    return true; 
} 
+0

tamam, çözüm bulundu ... Quickfix çekirdek düzenlemek veya Çekirdek/Model/Email.php gönderme işlevini genişletmektir. Orada, $ mail = yeni Zend_Mail() değiştirin; $ mail = yeni Zend_Mail ('utf-8'); kodlamayı utf-8 olarak ayarlayacak veya mağaza yapılandırmasından varsayılan kodlamayı alacak –

cevap

0

magento çekirdek genişletmek için uygun şekilde:

uygulama/kod/yerel/YOURTHEME/MODÜL/Modelinde

/Email.php

class YOURTHEME_MODULE_Model_Email extends Mage_Core_Model_Email{ 
    public function send() 
    { 
    if (Mage::getStoreConfigFlag('system/smtp/disable')) { 
     return $this; 
    } 

    $mail = new Zend_Mail('utf-8'); 

    if (strtolower($this->getType()) == 'html') { 
     $mail->setBodyHtml($this->getBody()); 
    } 
    else { 
     $mail->setBodyText($this->getBody()); 
    } 

    $mail->setFrom($this->getFromEmail(), $this->getFromName()) 
     ->addTo($this->getToEmail(), $this->getToName()) 
     ->setSubject($this->getSubject()); 
    $mail->send(); 

    return $this; 
    } 
} 

ve app/code/local/YOURTHEME/MODÜL/etc/config.xml dosyasında config.xml: