commerce_kickstart_migrate.migrate.inc in Commerce Kickstart 7.2
Contains base migration classes used by other Commerce Kickstart modules.
File
modules/commerce_kickstart/commerce_kickstart_migrate/commerce_kickstart_migrate.migrate.incView source
<?php
/**
* @file
* Contains base migration classes used by other Commerce Kickstart modules.
*/
/**
* Common features for all the migrations.
*/
abstract class CommerceKickstartMigration extends Migration {
/**
* {@inheritdoc}
*/
public function processImport(array $options = array()) {
parent::processImport($options);
// Do not force menu rebuilding. Otherwise pathauto will try to rebuild
// in each node_insert invocation.
variable_set('menu_rebuild_needed', FALSE);
}
}
/**
* Class CommerceKickstartPages.
*/
class CommerceKickstartPages extends CommerceKickstartMigration {
/**
* {@inheritdoc}
*/
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Import pages nodes.');
// 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_migrate') . '/import/pages.csv', $this
->csvcolumns(), array(
'header_rows' => 1,
));
$this->destination = new MigrateDestinationNode('page');
$this
->addFieldMapping('nid', 'nid');
$this
->addFieldMapping('title', 'title');
$this
->addFieldMapping('path', 'path');
$this
->addFieldMapping('body', 'body');
$this
->addFieldMapping('body:summary', 'excerpt');
$this
->addFieldMapping('uid', 'uid')
->defaultValue(1);
$this
->addFieldMapping('is_new', 'is_new')
->defaultValue(TRUE);
}
/**
* Returns CSV header mappings.
*
* @return mixed
* Array of mappings.
*/
public function csvcolumns() {
// "nid", "Title", "Path", "Body"
$columns[0] = array(
'nid',
'nid',
);
$columns[1] = array(
'title',
'Title',
);
$columns[2] = array(
'path',
'Path',
);
$columns[3] = array(
'body',
'Body',
);
return $columns;
}
}
Classes
Name | Description |
---|---|
CommerceKickstartMigration | Common features for all the migrations. |
CommerceKickstartPages | Class CommerceKickstartPages. |