Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Implementation Of Batch Process In Drupal

Parent Feed: 
/**
 * Generate batch process & its operations.
 */
function MYMODULE_build_batch() {
  $operations = array();

  // Here we can add multiple operation
   $operations[] = array('MYMODULE_process_data', array($arg1)); // operation with argument
   $operations[] = array('MYMODULE_process_data'); // operation without argument

  //Define your batch operation here
  $batch = array( 
    'title' => t('Batch operation processing'),
    'operations' => $operations,
    'finished' => 'MYMODULE_build_batch_finished',
    'init_message' => t('Initializing...'),
    'progress_message' => t('Operation @current out of @total.'),
    'error_message' => t('Found some error here.'),
    'file' => drupal_get_path('module', 'MYMODULE') . 'MYMODULE.module',
  );

  return $batch;
}
Author: 
Original Post: