After the Magento 1.9 edition, order confirmation emails aren’t sent quickly. Instead, they are queued up to be sent with the Cron job operation. This update changed the way the email queue works in Magento, resulting in better performance and reliability during the checkout process. And with that update, let me put a question in front of you,
Why are order emails send through the queue, while Invoice emails are sent directly?
Here, it is a list of reasons behind sending the orders email using the queue:
- To make the checkout/post-checkout process error-free: Generally, sending orders and emails in bulk will certainly affect website performance and you don’t want that because eCommerce website performance matters a lot..
- To avoid website slowdown: It is benefited by the re-send functionality in case of any failure or interruption.
- To resend, if not delivered: Organised and queued flow of orders emails can avoid discomfort while processing for checkout or even after it.
However, the order’s email can also be sent immediately, without queueing up. This approach is less common but gives you more control over how the email queue works in Magento in real time.
Send order email immediately:
If you like to send order email immediately you can consider overriding the Mage_Sales_Model_Order::queueNewOrderEmail() method by changing the following lines:
/** @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();
To:
/** @var $emailQueue Mage_Core_Model_Email_Queue */
$mailer->send();
If you want to send invoices using a queue for smooth sending, then also it can be achieved by the solution presented below.
Send invoices using the queue:
The opposite solution is to let invoices use the queue:
You must override Mage_Sales_Model_Order_Invoice::sendEmail changing:
// 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();
To:
// 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();
Hence, these are some code manipulations by which you can send orders email quickly or queue up invoice emails against immediate delivery.
Mastering how the email queue works in Magento helps your store send order emails smoothly and avoid delays. This improves customer experience and keeps your eCommerce website running faster and more reliably every day.
Feel free to leave your comments below, and contact us if you need any other help.
Post a Comment
Got a question? Have a feedback? Please feel free to leave your ideas, opinions, and questions in the comments section of our post! ❤️