Making a Batch with a number of features

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)?

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Making a Batch with a number of features

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.