private function GenerateProducts::batchGenerateProducts in Commerce Bulk 8
1 call to GenerateProducts::batchGenerateProducts()
- GenerateProducts::generateElements in modules/
commerce_generate/ src/ Plugin/ DevelGenerate/ GenerateProducts.php
File
- modules/
commerce_generate/ src/ Plugin/ DevelGenerate/ GenerateProducts.php, line 473
Class
- GenerateProducts
- Provides a GenerateProducts plugin.
Namespace
Drupal\commerce_generate\Plugin\DevelGenerateCode
private function batchGenerateProducts($values) {
if (!$this->drushBatch) {
// Setup the batch operations and save the variables.
$operations[] = [
'commerce_generate_operation',
[
$this,
'batchPrepareProduct',
$values,
],
];
}
// Add the kill operation.
if ($values['kill']) {
$operations[] = [
'commerce_generate_operation',
[
$this,
'batchProductKill',
$values,
],
];
}
// Add the operations to create the products.
for ($num = 0; $num < $values['num']; $num++) {
$operations[] = [
'commerce_generate_operation',
[
$this,
'batchGenerateSaveProduct',
$values,
],
];
}
$batch = [
'title' => $this
->t('Generating Products'),
'operations' => $operations,
'finished' => 'commerce_generate_batch_finished',
];
batch_set($batch);
if ($this->drushBatch) {
drush_backend_batch_process();
}
}