m7v
8/13/2015 - 3:18 PM

Remove orders via batch by condition.

Remove orders via batch by condition.

<?php
$order_ids = db_select('commerce_order', 'n')
  ->fields('n', array('order_id'))
  ->condition('n.created', 1439337600, '>=')
  ->execute()
  ->fetchCol();

foreach ($order_ids as $order_id) {
  $operations[] = array('commerce_order_delete', array($order_id));
}

$batch = array(
  'title' => t('Deleting'),
  'operations' => $operations
);
batch_set($batch);