You are here

public function Product::getYield in Commerce Migrate 3.1.x

Same name and namespace in other branches
  1. 8.2 modules/magento/src/Plugin/migrate/source/m2/Product.php \Drupal\commerce_migrate_magento\Plugin\migrate\source\m2\Product::getYield()
  2. 3.0.x modules/magento/src/Plugin/migrate/source/m2/Product.php \Drupal\commerce_migrate_magento\Plugin\migrate\source\m2\Product::getYield()

Prepare one row of product data.

@codingStandardsIgnoreStart

@codingStandardsIgnoreEnd

Parameters

\Generator $file: The source CSV file object.

Return value

\Generator A new row, one for each unique vocabulary.

1 call to Product::getYield()
Product::initializeIterator in modules/magento/src/Plugin/migrate/source/m2/Product.php

File

modules/magento/src/Plugin/migrate/source/m2/Product.php, line 69

Class

Product
Gets the product rows.

Namespace

Drupal\commerce_migrate_magento\Plugin\migrate\source\m2

Code

public function getYield(\Generator $file) {
  foreach ($file as $row) {
    $variations = $this
      ->getVariations($row);
    $count = count($variations);

    // Yield a row if this product has one variation or if it configurable and
    // has more than product variation.
    if ($count === 1 || $count > 1 && $row['product_type'] === 'configurable') {

      // Get the variations and write.
      $new_row = $row;
      $new_row['variations'] = $variations;
      (yield $new_row);
    }
  }
}