You are here

public function ContentImporter::onInstall in Commerce Demo 8.2

Same name and namespace in other branches
  1. 8 src/ContentImporter.php \Drupal\commerce_demo\ContentImporter::onInstall()

Reacts on the module being installed, imports all content.

File

src/ContentImporter.php, line 55

Class

ContentImporter
Defines the content importer.

Namespace

Drupal\commerce_demo

Code

public function onInstall() {

  // It is necessary to hardcode the available entity types/bundles to ensure
  // the right import order, because there is no dependency tracking.
  $available_content = [
    [
      'taxonomy_term',
      'brands',
    ],
    [
      'taxonomy_term',
      'product_categories',
    ],
    [
      'taxonomy_term',
      'special_categories',
    ],
    [
      'commerce_store',
      'online',
    ],
    [
      'commerce_product_attribute_value',
      'color',
    ],
    [
      'commerce_product_attribute_value',
      'size',
    ],
    [
      'commerce_product',
      'clothing',
    ],
    [
      'commerce_product',
      'simple',
    ],
    [
      'commerce_shipping_method',
      '',
    ],
    [
      'commerce_promotion',
      '',
    ],
    [
      'commerce_pricelist',
      'commerce_product_variation',
    ],
    [
      'commerce_pricelist_item',
      'commerce_product_variation',
    ],
  ];
  foreach ($available_content as $keys) {
    $this
      ->importAll($keys[0], $keys[1]);
  }
}