You are here

commerce_feedsmulti.install in Commerce Feeds multitype 7

Install, update, and uninstall functions for the Commerce Feeds multitype module.

File

commerce_feedsmulti.install
View source
<?php

/**
 * @file
 * Install, update, and uninstall functions for the Commerce Feeds multitype
 * module.
 */

/**
 * Update to use generic bundle handling.
 *
 * @see feeds_update_7208()
 * @see https://www.drupal.org/node/2426449
 */
function commerce_feedsmulti_update_7100(&$sandbox) {
  if (!isset($sandbox['importers'])) {

    // Get all importers.
    $sandbox['importers'] = db_query("SELECT id FROM {feeds_importer}")
      ->fetchCol();
    $sandbox['total'] = count($sandbox['importers']);
  }
  $importer = array_pop($sandbox['importers']);
  $config = db_query("SELECT config FROM {feeds_importer} WHERE id = :id", array(
    ':id' => $importer,
  ))
    ->fetchField();
  if ($config) {
    $config = unserialize($config);
    switch ($config['processor']['plugin_key']) {
      case 'FeedsCommerceProductMultiProcessor':
        $config_key = 'product_type';
        break;
      default:
        $config_key = FALSE;
        break;
    }
    if ($config_key && isset($config['processor']['config'][$config_key])) {
      $config['processor']['config']['bundle'] = $config['processor']['config'][$config_key];
      unset($config['processor']['config'][$config_key]);

      // Update database.
      db_update('feeds_importer')
        ->fields(array(
        'config' => serialize($config),
      ))
        ->condition('id', $importer)
        ->execute();
    }
    $sandbox['#finished'] = 1 - count($sandbox['importers']) / $sandbox['total'];
  }
  else {
    $sandbox['#finished'] = 1;
  }
}

Functions

Namesort descending Description
commerce_feedsmulti_update_7100 Update to use generic bundle handling.