How to disable email sending when programatically creating an order in Magento

How to disable email sending when programatically creating an order in Magento

Here is a little snippet of code that can come in handy if you are like me handling a task of programatically creating an order in Magento. My issue was that I had to disable emails beeing sent out to the customers, while at the same time leave the normal frontend process. Thus I could not just go under Magento admin System > Congifuration and disable email sending from there.

Here is the sample line code you just need to place above final $order->save() or possibly $checkout->saveOrder():

Mage::app()->getStore()->setConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_ENABLED, "0");

You made it all the way down here so you must have enjoyed this post! You may also like:

Enabling Multi-part MIME Emails in Magento Tomislav Nikcevski
Tomislav Nikcevski

Enabling Multi-part MIME Emails in Magento

Extending “Contact us” functionality in Magento Ivan Bernatovic
Ivan Bernatovic

Extending “Contact us” functionality in Magento

Magento’s transactional eMails do-s and don’t-s Adrian Bece
Adrian Bece

Magento’s transactional eMails do-s and don’t-s

Tell us about your project

Drop us a line. We'd love to know more about your project.