我添加了自定義功能,可以將發票電子郵件發送到其他一些郵件地址(不包括客戶& admin)。爲此,我呼籲以觀察員將發票電子郵件發送到magento的自定義郵件地址
<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 = '[email protected]';//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);
}
}
一切正常,除了,產品信息未在模板中顯示的罰款。
有人可以弄清楚我做錯了什麼嗎?
您是否解決了這個問題? –