3

We're working on importing orders from a legacy system into a Magento 1.9.2.3 store.

We have a script that creates the customer if he doesn't exist and creates the order.

We want to make sure that no emails get sent out from Magento for any of these orders.

We initially setup our script as such

<?php

//Disable all emails
Mage::app()->getConfig()->saveConfig('system/smtp/disable', '1', 'default', 0);

//run import 


//Re-enable all emails
Mage::app()->getConfig()->saveConfig('system/smtp/disable', '0', 'default', 0);

?>

We have two concerns with this approach

  1. If a customer places an order during the time that our script is running - they won't get a confirmation
  2. Since Magento now sends the emails through a queue and a cron, if our script is finished by time the cron runs, the emails will still get sent out.

What would be a better way to ensure that no emails get sent out as a result of our importing legacy orders?

  • 1
    It would be good to see the code which is creating the orders as there are a few different approaches. – Andreas von Studnitz Aug 28 '17 at 17:41
  • Email sending should be disable during order creation ... want to share some code? – sv3n Oct 31 '18 at 19:20
  • @svn what are you asking? – Haim Oct 31 '18 at 23:51
0

If you have AOE_Scheduler installed, you can disable the email queue processing, prior to running your import script.

aoe

Then, after you have run your script, use the comma-separated entity_ids of the orders you created in the following MySQL query.

delete from core_email_queue
where entity_type = 'order'
    and entity_id in ('111','222','333');

This will remove the order emails from the queue. Then, you can re-enable the cron in AOE_Scheduler.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.