i am making an attempt to optimise my setup of a Drupal Batch course of.
I’m studying in 1000’s of rows of knowledge from an Excel spreadsheet, from a number of worksheets, and creating nodes from Drupal Developer Rows. My import features work fantastic, and I can create a Batch, however at current I’m making a batch operation for every row. Which means my batch could be very sluggish (as a result of I am having to bootstrap Drupal on each row).
What I can not appear to determine is a approach to setup my batch to take care of ‘chunks’ slightly than particular person rows.
An instance of my import operate (of which there are 18) is:
operate governbim_coordinate($worth){ module_load_include('inc','phpexcel'); world $consumer; $challenge = $_SESSION['governbim']['projnid']; //Load Drupal Developer required worksheet from Drupal Developer excel file handed to Drupal Developer operate as $worth $end result = phpexcel_import($worth,TRUE,TRUE,array('setLoadSheetsOnly' => array('Coordinate'))); //Outline some frequent values for our entity $values = array( 'sort' => 'coordinate', 'uid' => $user->uid, 'standing' => 1, 'remark' => 0, 'promote' => 0, ); //step by way of every row in Drupal Developer worksheet foreach($end result['Coordinate'] as $coordinate){ $title = $coordinate['Name']; //examine to see if this can be a new row or if we're updating an present entity $motion = governbim_node_actions_node_check('meeting',$title); swap($motion['op']){ case 'new': $e = entity_create('node',$values); $entity = entity_metadata_wrapper('node',$e); break; case 'replace': $e = entity_create('node',$values); $entity = entity_metadata_wrapper('node',$motion['nid']); break; } //*** Right here is the place we write the whole lot to Drupal Developer database with Drupal Developer entity values and $entity->save() ****/ } }
My batch is setup (at present) as:
operate governbim_excel_import_batch(){ drupal_set_message("Importing Knowledge..."); $path = 'public://imports/'; $file = 'COBie-UK-2012-example1.xls'; $datafile = $path.$file; $operations[]=array('governbim_coordinate',array($datafile)); //one other 17 $operations[] outlined as above $batch = array( 'operations' => $operations, 'init_message' => t('Developing batch operation...'), 'progress_message' => t('Importing Excel knowledge'), 'completed' => 'governbim_excel_import_batch_finished', 'error_message' => t('Importing of Excel knowledge encountered an error.'), ); return $batch; }
I realise I must get some $context stuff into Drupal Developer import operate, however I can not appear to determine how one can setup that side correctly.
Is anybody in a position to help me in re-tuning issues in order that I can get Drupal Developer batch (with 18 operate calls) to show progress of Drupal Developer general batch and get Drupal Developer batch to execute (say) teams of iterations (as in $restrict = 10)?