You are here

function commerce_kickstart_import_content in Commerce Kickstart 7.2

Task callback: return a batch API array with the products to be imported.

File

./commerce_kickstart.install, line 397
Installation code for Commerce Kickstart.

Code

function commerce_kickstart_import_content() {

  // Fixes problems when the CSV files used for importing have been created
  // on a Mac, by forcing PHP to detect the appropriate line endings.
  ini_set("auto_detect_line_endings", TRUE);
  $operations = array();
  $operations[] = array(
    '_commerce_kickstart_example_taxes',
    array(
      t('Setting up taxes.'),
    ),
  );
  $install_demo_store = variable_get('commerce_kickstart_demo_store', FALSE);
  $operations[] = array(
    '_commerce_kickstart_taxonomy_menu',
    array(
      t('Setting up menus.'),
    ),
  );

  // Run all available migrations.
  $migrations = migrate_migrations();
  foreach ($migrations as $machine_name => $migration) {
    $operations[] = array(
      '_commerce_kickstart_import',
      array(
        $machine_name,
        t('Importing content.'),
      ),
    );
  }
  if ($install_demo_store) {
    $operations[] = array(
      '_commerce_kickstart_example_user',
      array(
        t('Setting up users.'),
      ),
    );
  }

  // Perform post-import tasks.
  $operations[] = array(
    '_commerce_kickstart_post_import',
    array(
      t('Completing setup.'),
    ),
  );
  $batch = array(
    'title' => t('Importing content'),
    'operations' => $operations,
    'file' => drupal_get_path('profile', 'commerce_kickstart') . '/commerce_kickstart.install_callbacks.inc',
  );
  return $batch;
}