Email pesanan dikirim menggunakan antrian karena berbagai alasan:
- Hindari perlambatan frontend saat mengirim email
- Kirim ulang pada kegagalan
- Hindari kesalahan pada checkout / post-checkout
Solusi 1 (kirim email pesanan segera):
Jika Anda ingin segera mengirim email pesanan, Anda dapat mempertimbangkan untuk mengganti Mage_Sales_Model_Order::queueNewOrderEmail()
metode dengan mengganti baris berikut:
/** @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();
untuk:
/** @var $emailQueue Mage_Core_Model_Email_Queue */
$mailer->send();
Solusi 2 (mengirim faktur menggunakan antrian):
Solusi sebaliknya adalah membiarkan faktur menggunakan antrian:
Anda harus mengganti Mage_Sales_Model_Order_Invoice::sendEmail
perubahan:
// 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();
Untuk:
// 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();