新创建的电子邮件模板中缺少订单项

时间:2017-02-11 23:51:24

标签: magento module email-templates

我已经创建了一个新的观察员,在订单付款后发送,发送电子邮件给我的供应商以生产我需要的商品。 因此,除了订单商品列表外,我收到了包含所有数据的电子邮件。此外,数据的格式与标准order_new.html不同。布局错误,似乎缺少css样式问题。

在此之前,我在template / email / sales文件夹中有html文件,例如order_new.html,我只收到一封空邮件。所以我把文件放在模板/电子邮件中,现在我收到了那个worng布局,没有订单商品。

我不明白为什么。你能帮我解决这个问题吗?

所以这是我的Oberser.php代码

<?php
class Electricjesus_Notifyowner_Model_Observer
{
 public function notifyOwnerEvent($observer)
{

    // parameters you can get from the $observer parameter:
    // array(’payment’ ? $this, ‘invoice’ ? $invoice)

    $payment = $observer->getPayment();
    $invoice = $observer->getInvoice();

    // derivative data
    $order = $invoice->getOrder(); // Mage_Sales_Model_Order

    $ownerEmail = 'xxxx6@gmail.com';
    $Subject = 'Oggetto :';
    $emailTemplate  = Mage::getModel('core/email_template')
        ->loadDefault('order_copy_for_supplier');
    $emailTemplate->setTemplateSubject('Prova di Ordine Confermato dopo pagamento');
    $emailTemplate->setToName($senderName);
    $emailTemplate->setToEmail($ownerEmail);
    $emailTemplate->setBody($processedTemplate);
    $emailTemplate->setSubject($Subject);
    $emailTemplate->setFromEmail($senderEmail);
    $emailTemplate->setFromName($senderName);
     $emailTemplate->setType('html');

    // Get General email address (Admin->Configuration->General->Store Email Addresses)
    $salesData['email'] = Mage::getStoreConfig('trans_email/ident_general/email');
    $salesData['name'] = Mage::getStoreConfig('trans_email/ident_general/name');

    $emailTemplate->setSenderName($salesData['name']);
    $emailTemplate->setSenderEmail($salesData['email']);

   //Getting the Store E-Mail Sender Name.
    $senderName = Mage::getStoreConfig('trans_email/ident_general/name');

    //Getting the Store General E-Mail.
    $senderEmail = Mage::getStoreConfig('trans_email/ident_general/email');
    $emailTemplateVariables['order'] = $order;
    $emailTemplateVariables['username']  = $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname();
    $emailTemplateVariables['order_id'] = $order->getIncrementId();
    $emailTemplateVariables['store_name'] = $order->getStoreName();
    $emailTemplateVariables['order_data'] = $order->getCreatedAtFormated();
    $emailTemplateVariables['store_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);   
    $emailTemplate->send($ownerEmail, $order->getStoreName(), $emailTemplateVariables);

    //$processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
    //$mailTemplate = Mage::getModel('core/email')
    //->setToName($senderName)
    //->setToEmail($ownerEmail)
    //->setBody($processedTemplate)
    //->setSubject($Subject)
     //->setFromEmail($senderEmail)
     //->setFromName($senderName)
     //->setType('html');
     //try{
     //Confimation E-Mail Send
     //$mail->send();
     //}
     //catch(Exception $error)
     //{
     //Mage::getSingleton('core/session')->addError($error->getMessage());
     //return false;
     //}


    return $this;  // always return $this.
}




}

这是我的config.xml

<?xml version="1.0"?>
<config>
<modules>
    <Electricjesus_Notifyowner>
            <version>0.1.0</version>
    </Electricjesus_Notifyowner>
</modules>
<global>
    <models>
        <notifyowner>
            <class>Electricjesus_Notifyowner_Model</class>
        </notifyowner>
    </models>          
    <events>
            <sales_order_payment_pay>
                <observers>
                    <notifyOwnerEvent>
                            <class>notifyowner/observer</class>
                            <method>notifyOwnerEvent</method>
                    </notifyOwnerEvent>
                </observers>
            </sales_order_payment_pay >     
    </events>
    <template>
        <email>
            <order_copy_for_supplier module="Electricjesus_Notifyowner">
                <label>Nuovo Ordine Per Fornitore</label>
                <file>order_copy_for_supplier.html</file>
                <type>html</type>
            </order_copy_for_supplier>
        </email>
    </template>
 </global>

这是我的模板:

<!--@subject {{var store.getFrontendName()}}: Nuovo Ordine Per        Fornitore # {{var order.increment_id}} @-->
<!--@vars
{"store url=\"\"":"Store Url",
"var logo_url":"Email Logo Image Url",
"var logo_alt":"Email Logo Image Alt",
"htmlescape var=$order.getCustomerName()":"Customer Name",
"var store.getFrontendName()":"Store Name",
"store url=\"customer/account/\"":"Customer Account Url",
"var order.increment_id":"Order Id",
"var order.getCreatedAtFormated('long')":"Order Created At (datetime)",
"var order.getBillingAddress().format('html')":"Billing Address",
"var payment_html":"Payment Details",
"var order.getShippingAddress().format('html')":"Shipping Address",
"var order.getShippingDescription()":"Shipping Description",
"layout handle=\"sales_email_order_items\" order=$order":"Order Items Grid",
"var order.getEmailCustomerNote()":"Email Order Note"}
@-->
<!--@styles
@-->

{{template config_path="design/email/header"}}
{{inlinecss file="email-inline.css"}}

<table cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td>
            <table cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td class="email-heading">
                        <h1>Nuovo ordine da produrre{{var store.getFrontendName()}}.</h1>
                        <p>Gentile Fornitore, vi preghiamo di mettere in produzione il seguente ordine. </p>
                    </td>
                    <td class="store-info">
                        <h4>Info da inviare a </h4>
                        <p>
                            {{depend store_phone}}
                            <b>Chiamaci:</b>
                            <a href="tel:{{var phone}}">{{var store_phone}}</a><br>
                            {{/depend}}
                            {{depend store_hours}}
                            <span class="no-link">{{var store_hours}}</span><br>
                            {{/depend}}
                            {{depend store_email}}
                            <b>Email:</b> <a href="mailto:{{var store_email}}">{{var store_email}}</a>
                            {{/depend}}
                        </p>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td class="order-details">
            <h3>Ns. Ordine N. <span class="no-link">#{{var order.increment_id}}</span></h3>
            <p>Effettuato il {{var order.getCreatedAtFormated('long')}}</p>
        </td>
    </tr>
    <tr class="order-information">
        <td>
            {{if order.getEmailCustomerNote()}}
            <table cellspacing="0" cellpadding="0" class="message-container">
                <tr>
                    <td>{{var order.getEmailCustomerNote()}}</td>
                </tr>
            </table>
            {{/if}}
            {{layout handle="sales_email_order_items" order=$order}}
            <table cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td class="address-details">
                        <h6>Fattura a:</h6>
                        <p><span class="no-link">{{var order.getBillingAddress().format('html')}}</span></p>
                    </td>
                    {{depend order.getIsNotVirtual()}}
                    <td class="address-details">
                        <h6>Spedizione a:</h6>
                        <p><span class="no-link">{{var order.getShippingAddress().format('html')}}</span></p>
                    </td>
                    {{/depend}}
                </tr>
                <tr>
                    {{depend order.getIsNotVirtual()}}
                    <td class="method-info">
                        <h6>Metodo di spedizione:</h6>
                        <p>{{var order.shipping_description}}</p>
                    </td>
                    {{/depend}}
                    <td class="method-info">
                        <h6>Metodo di pagamento:</h6>
                        {{var payment_html}}
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>

    {{template config_path="design/email/footer"}}

0 个答案:

没有答案