function commerce_bulk_commerce_bulk_variation_alter in Commerce Bulk 8
Implements hook_commerce_bulk_variation_alter().
File
- ./
commerce_bulk.module, line 22 - Contains commerce_bulk.module.
Code
function commerce_bulk_commerce_bulk_variation_alter(array &$variations, $data = '', $product_type = '') {
if ($product_type == 'my_product_type') {
// Optionally, decode 'json' or 'xml' data passed on the VBO action
// configuration page and use that to alter variations.
// $array_data = \Drupal::service('serializer')->decode($data, 'json');.
foreach ($variations as $variation) {
// Enable core `Serialization' module to decode the string $data.
// Do something and save variation.
// The parent product will be saved later by the hook caller.
// $variation->save();
}
}
}