You are here

public function CommerceKickstartNode::__construct in Commerce Kickstart 7.2

Same name in this branch
  1. 7.2 modules/commerce_kickstart/commerce_kickstart_product/commerce_kickstart_product.migrate.inc \CommerceKickstartNode::__construct()
  2. 7.2 modules/commerce_kickstart/commerce_kickstart_lite_product/commerce_kickstart_lite_product.migrate.inc \CommerceKickstartNode::__construct()

General initialization of a Migration object.

Overrides Migration::__construct

File

modules/commerce_kickstart/commerce_kickstart_product/commerce_kickstart_product.migrate.inc, line 587
Migrations for commerce_kickstart_product.

Class

CommerceKickstartNode
Class CommerceKickstartNode.

Code

public function __construct($arguments) {
  parent::__construct($arguments);
  $this->description = t('Import product nodes.');
  $this->dependencies = array(
    'CommerceKickstartBagsCases',
    'CommerceKickstartDrinks',
    'CommerceKickstartHats',
    'CommerceKickstartShoes',
    'CommerceKickstartStorage',
    'CommerceKickstartTops',
    'CommerceKickstartPages',
  );

  // Create a map object for tracking the relationships between source rows.
  $this->map = new MigrateSQLMap($this->machineName, array(
    'title' => array(
      'type' => 'varchar',
      'length' => 255,
      'not null' => TRUE,
    ),
  ), MigrateDestinationNode::getKeySchema());

  // Create a MigrateSource object.
  $this->source = new MigrateSourceCSV(drupal_get_path('module', 'commerce_kickstart_product') . '/import/product_display_' . $arguments['type'] . '.csv', $this
    ->csvcolumns(), array(
    'header_rows' => 1,
  ));
  $this->destination = new MigrateDestinationNode($arguments['type']);
  $this
    ->addFieldMapping('uid', 'uid')
    ->defaultValue(1);
  $this
    ->addFieldMapping('title', 'title');
  $this
    ->addFieldMapping('body', 'description');
  $this
    ->addFieldMapping('body:summary', 'excerpt');
  $this
    ->addFieldMapping('field_brand', 'brand');
  $this
    ->addFieldMapping('field_brand:create_term')
    ->defaultValue(TRUE);
  $this
    ->addFieldMapping('field_category', 'category');
  $this
    ->addFieldMapping('field_category:create_term')
    ->defaultValue(TRUE);
  $this
    ->addFieldMapping('field_collection', 'collection')
    ->separator(', ');
  $this
    ->addFieldMapping('field_collection:create_term')
    ->defaultValue(TRUE);
  $this
    ->addFieldMapping('field_gender', 'gender');
  $this
    ->addFieldMapping('field_gender:create_term')
    ->defaultValue(TRUE);
  $this
    ->addFieldMapping('field_product', 'skus');
}