function commerce_feedsmulti_update_7100 in Commerce Feeds multitype 7
Update to use generic bundle handling.
See also
https://www.drupal.org/node/2426449
File
- ./
commerce_feedsmulti.install, line 14 - Install, update, and uninstall functions for the Commerce Feeds multitype module.
Code
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;
}
}