2011-01-26 5 views
0

大量の顧客をmagentoデータベースにインポートするカスタムスクリプトを作成しました。クライアントが必要とするのは、100人の顧客のインポートごとに、何が起こっているかについてのメールとインポートのステータスが必要でした。カスタムスクリプトのMagentoメール機能

どのように私はマゼンタのようにメールを送信するためのテンプレートを作成できるように、マゼンタのメール機能を使用することができます。助けてください

答えて

0

またここでZEND

のメーリング機能を行うことができますことは、この1は私が望んでいたまさに取り組んでいるコード

$mail_body = "<h3> These are ordered by you in the event - '".$customer_event."' </h3> <br/>". $email_body;   
     $to_email = $email; 
     $to_name = $customer_name; 
     $subject = 'Orders'; 
     $Body  = $body; 
     $sender_email = "[email protected]"; 
     $sender_name = "mail"; 


     $html = new Zend_View(); 
     $html->setScriptPath('app/locale/en_US/template/email/'); 

     $html->assign('customer_name', $customer_name); 
     $html->assign('email', $to_email); 
     $html->assign('password', $password); 
     $html->assign('site_url', Mage::getUrl("")); 
     $html->assign('site_skin_url', Mage::getDesign()->getSkinUrl("images/")); 
     $html->assign('site_order_url', Mage::getUrl("").'Event.php?id='.$id.'&cart_id='.$cart_id); 
     $html->assign('site_name', 'Winecellarage'); 
     $html->assign('site_data', $mail_body); 

     $Body_text= $html->render($template); 
     $mail = new Zend_Mail('utf-8');  
     $mail->setBodyHtml($Body_text); 
     $mail->setFrom($sender_email, $sender_name); 
     $mail->addTo($to_email, $to_name); 
     //$mail->addCc($cc, $ccname); 
     //$mail->addBCc($bcc, $bccname); 
     $mail->setSubject($subject); 
     try { 
       if($mail->send()) 
       { 
       $msg .= "<p>Mail sent successfully to '$to_email' </p>"; 
       } 
     } 
     catch(Exception $ex) { 
       $err .= '<p>'.$error_msg = $ex->getMessage()."</p>"; 
     }  

です。だから、ある人にとっては役に立つかもしれない。

1

インポートスクリプトからこれを行う場合は、PHP mail関数で十分です。

+0

はいメール機能は現在使用している機能です。しかし、すべての顧客のメールに2つの通知を送信してインポートした後、私はmagentoテンプレートのコンセプトを使用したいと思います。それが理由です – Elamurugan

4

は、私はあなたが以下の線に沿って何かを探していると思う:

$store_id = $this->getStoreId(); 
$template = "import_script_email_template_name"; 

$from = Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $store_id); 
$to = array("name" => "Nick", "email" => "[email protected]"); 

$template_variables = array(
    "var1" => "somevalue", 
    "var2" => "someothervalue" 
); 


$mail = Mage::getModel("core/email_template"); 
$mail->setDesignConfig(array("area" => "frontend", "store" => $store_id)) 
    ->sendTransactional(
     $template_name, 
     $from, 
     $to["email"], 
     $to["name"], 
     $template_variables 
    ); 

注:これはMage_Sales_Model_Order::sendNewOrderEmail()から解除されたとテストされていないが、それは取得するのに十分以上にする必要がありますあなたは始まった。擬似コードとして扱い:)

関連する問題