You are here

protected function ContentExporter::processProduct in Commerce Demo 8

Same name and namespace in other branches
  1. 8.2 src/ContentExporter.php \Drupal\commerce_demo\ContentExporter::processProduct()

Processes the exported product.

Parameters

array $export: The export array.

\Drupal\commerce_product\Entity\ProductInterface $product: The product.

Return value

array The processed export array.

1 call to ContentExporter::processProduct()
ContentExporter::export in src/ContentExporter.php
Exports the given entity.

File

src/ContentExporter.php, line 206

Class

ContentExporter
Defines the content exporter.

Namespace

Drupal\commerce_demo

Code

protected function processProduct(array $export, ProductInterface $product) {

  // Export the variations as well.
  $variations = [];
  foreach ($product
    ->getVariations() as $variation) {
    $variations[$variation
      ->uuid()] = $this
      ->export($variation);

    // The array is keyed by UUID, no need to have it in the export too.
    unset($variations[$variation
      ->uuid()]['uuid']);
  }
  $export['variations'] = $variations;
  return $export;
}