我添加了自定义功能,可以将发票电子邮件发送到其他一些邮件地址(不包括客户和管理员)。为此我在观察者中调用了自定义函数
<sales_order_invoice_save_after>
<observers>
<test>
<type>singleton</type>
<class>test/observer</class>
<method>sentMailToothers</method>
</test>
</observers>
观察员代码
$template_id = 'sales_email_invoice_template';
$emailTemplate = Mage::getModel('core/email_template')->loadDefault($template_id);
$storeId = Mage::app()->getStore()->getStoreId();
$invoice = $observer->getEvent()->getInvoice();
$order = $observer->getEvent()->getInvoice()->getOrder();
if ($order->hasInvoices())
{
foreach ($order->getInvoiceCollection() as $inv)
{
$paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment())->setIsSecureMode(true);
$paymentBlockHtml = $paymentBlock->toHtml();
$email_to = 'test@test.com';//dynamic email address
$customer_name = 'Test'
$email_template_variables = array(
'order' => $order,
'invoice' => $invoice,
'payment_html' => $paymentBlockHtml
);
$sender_name = Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_STORE_STORE_NAME);
$sender_email = Mage::getStoreConfig('trans_email/ident_general/email');
$emailTemplate->setSenderName($sender_name);
$emailTemplate->setSenderEmail($sender_email);
$processedTemplate = $emailTemplate->getProcessedTemplate($email_template_variables);
echo $processedTemplate;die;
//Send the email!
$emailTemplate->send($email_to, $customer_name, $email_template_variables);
}
}
一切正常,但产品信息未显示在模板中。
有人可以弄清楚我做错了什么吗?