Answers:
使用队列发送订单电子邮件的原因有多种:
解决方案1(立即发送订单的电子邮件):
如果您想立即发送订单电子邮件,可以考虑Mage_Sales_Model_Order::queueNewOrderEmail()
通过链接以下几行来覆盖该方法:
/** @var $emailQueue Mage_Core_Model_Email_Queue */
$emailQueue = Mage::getModel('core/email_queue');
$emailQueue->setEntityId($this->getId())
->setEntityType(self::ENTITY)
->setEventType(self::EMAIL_EVENT_NAME_NEW_ORDER)
->setIsForceCheck(!$forceMode);
$mailer->setQueue($emailQueue)->send();
至:
/** @var $emailQueue Mage_Core_Model_Email_Queue */
$mailer->send();
解决方案2(使用队列发送发票):
相反的解决方案是让发票使用队列:
您必须覆盖Mage_Sales_Model_Order_Invoice::sendEmail
更改:
// Set all required params and send emails
$mailer->setSender(Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId));
$mailer->setStoreId($storeId);
$mailer->setTemplateId($templateId);
$mailer->setTemplateParams(array(
'order' => $order,
'invoice' => $this,
'comment' => $comment,
'billing' => $order->getBillingAddress(),
'payment_html' => $paymentBlockHtml
)
);
$mailer->send();
至:
// Set all required params and send emails
$mailer->setSender(Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId));
$mailer->setStoreId($storeId);
$mailer->setTemplateId($templateId);
$mailer->setTemplateParams(array(
'order' => $order,
'invoice' => $this,
'comment' => $comment,
'billing' => $order->getBillingAddress(),
'payment_html' => $paymentBlockHtml
)
);
$emailQueue = Mage::getModel('core/email_queue');
$emailQueue->setEntityId($this->getId())
->setEntityType('order_invoice')
->setEventType('new_invoice');
$mailer->setQueue($emailQueue)->send();