Commit 8074fc50 authored by Matt Glaman's avatar Matt Glaman

Merge pull request #122 from mglaman/commerce-kickstart-migrate-update

Update Migrate API integration
parents 439609f4 c6a7c2df
......@@ -35,6 +35,7 @@ projects[commerce_autosku][download][type] = git
projects[commerce_autosku][download][revision] = 562b9a5
projects[commerce_autosku][download][branch] = 7.x-1.x
projects[commerce_migrate][version] = 1.1
projects[commerce_migrate][patch][1931302] = https://www.drupal.org/files/commerce_products_source_migration-1931302-2.patch
projects[commerce_discount][version] = 1.x-dev
projects[commerce_discount][download][type] = git
projects[commerce_discount][download][revision] = 7a78225
......@@ -101,7 +102,7 @@ projects[token][patch][] = "http://drupal.org/files/token-token_asort_tokens-171
projects[eva][version] = 1.2
projects[message][version] = 1.10
projects[message_notify][version] = 2.5
projects[migrate][version] = 2.5
projects[migrate][version] = 2.8
projects[migrate_extras][version] = 2.5
projects[migrate_extras][patch][] = "http://drupal.org/files/migrate_extras-fix-destid2-array-1951904-4.patch"
projects[date][version] = 2.8
......
......@@ -2,13 +2,19 @@
/**
* @file
* Migrations for commerce_kickstart_blog.
* Migrations for commerce_kickstart_blog.
*/
/**
* Class CommerceKickstartBlogPost.
*/
class CommerceKickstartBlogPost extends CommerceKickstartMigration {
public function __construct() {
parent::__construct();
/**
* {@inheritdoc}
*/
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Import blog-post nodes.');
$this->dependencies = array('CommerceKickstartPages');
......@@ -48,7 +54,13 @@ class CommerceKickstartBlogPost extends CommerceKickstartMigration {
$this->addFieldMapping('uid', 'uid')->defaultValue(1);
}
function csvcolumns() {
/**
* Returns CSV header mappings.
*
* @return mixed
* Array of mappings.
*/
public function csvcolumns() {
// "Title", "Images", "Tags", "Body"
$columns[0] = array('title', 'Title');
$columns[1] = array('images', 'Images');
......
......@@ -2,13 +2,19 @@
/**
* @file
* Migrations for commerce_kickstart_lite_product.
* Migrations for commerce_kickstart_lite_product.
*/
/**
* Class CommerceKickstartProduct.
*/
class CommerceKickstartProduct extends CommerceKickstartMigration {
public function __construct() {
parent::__construct();
/**
* {@inheritdoc}
*/
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Import products.');
// Create a map object for tracking the relationships between source rows
......@@ -20,7 +26,7 @@ class CommerceKickstartProduct extends CommerceKickstartMigration {
'not null' => TRUE,
),
),
MigrateDestinationEntityAPI::getKeySchema('commerce_product', 'product')
MigrateDestinationEntityAPI::getKeySchema('commerce_product')
);
// Create a MigrateSource object.
......@@ -43,7 +49,13 @@ class CommerceKickstartProduct extends CommerceKickstartMigration {
$this->addFieldMapping('language', 'language');
}
function csvcolumns() {
/**
* Maps CSV column headers.
*
* @return array
* Array of mappings
*/
public function csvcolumns() {
$columns[0] = array('title', 'Title');
$columns[1] = array('sku', 'SKU');
$columns[2] = array('price', 'Price');
......@@ -52,24 +64,38 @@ class CommerceKickstartProduct extends CommerceKickstartMigration {
return $columns;
}
function fields() {
/**
* Returns mapping for fields.
*
* @return array
* Array of fields names and description.
*/
public function fields() {
return array(
'product_images' => 'An array of images, populated during prepareRow().',
);
}
function prepareRow($row) {
/**
* {@inheritdoc}
*/
public function prepareRow($row) {
$row->product_images = explode(', ', $row->images);
$row->uid = 1;
$row->language = LANGUAGE_NONE;
}
}
/**
* Class CommerceKickstartNode.
*/
class CommerceKickstartNode extends CommerceKickstartMigration {
public function __construct() {
parent::__construct();
/**
* {@inheritdoc}
*/
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Import product nodes.');
$this->dependencies = array(
......@@ -104,6 +130,9 @@ class CommerceKickstartNode extends CommerceKickstartMigration {
$this->addFieldMapping('field_product', 'skus');
}
/**
* {@inheritdoc}
*/
public function prepareRow($row) {
$products = array();
foreach (explode(', ', $row->sku) as $sku) {
......@@ -113,6 +142,12 @@ class CommerceKickstartNode extends CommerceKickstartMigration {
$row->skus = $products;
}
/**
* Maps CSV column headers.
*
* @return array
* Array of mappings
*/
function csvcolumns() {
$columns[0] = array('title', 'Title');
$columns[1] = array('description', 'Description');
......
......@@ -2,13 +2,19 @@
/**
* @file
* Migrations for commerce_kickstart_merchandising.
* Migrations for commerce_kickstart_merchandising.
*/
/**
* Class CommerceKickstartAdPush.
*/
class CommerceKickstartAdPush extends CommerceKickstartMigration {
public function __construct() {
parent::__construct();
/**
* {@inheritdoc}
*/
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Import ad-push nodes.');
$this->softDependencies = array('CommerceKickstartPages');
......@@ -42,7 +48,13 @@ class CommerceKickstartAdPush extends CommerceKickstartMigration {
$this->addFieldMapping('uid', 'uid')->defaultValue(1);
}
function csvcolumns() {
/**
* Maps CSV column headers.
*
* @return array
* Array of mappings
*/
public function csvcolumns() {
// "Title", "Tagline", "Link", "Images"
$columns[0] = array('title', 'Title');
$columns[1] = array('tagline', 'Tagline');
......
......@@ -2,7 +2,7 @@
/**
* @file
* Contains base migration classes used by other Commerce Kickstart modules.
* Contains base migration classes used by other Commerce Kickstart modules.
*/
/**
......@@ -10,21 +10,31 @@
*/
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 {
public function __construct() {
parent::__construct();
/**
* {@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
// Create a map object for tracking the relationships between source rows.
$this->map = new MigrateSQLMap($this->machineName,
array(
'title' => array(
......@@ -51,7 +61,13 @@ class CommerceKickstartPages extends CommerceKickstartMigration {
$this->addFieldMapping('is_new', 'is_new')->defaultValue(TRUE);
}
function csvcolumns() {
/**
* 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');
......@@ -59,4 +75,5 @@ class CommerceKickstartPages extends CommerceKickstartMigration {
$columns[3] = array('body', 'Body');
return $columns;
}
}
......@@ -2,13 +2,19 @@
/**
* @file
* Migrations for commerce_kickstart_slideshow.
* Migrations for commerce_kickstart_slideshow.
*/
/**
* Class CommerceKickstartSlideshow.
*/
class CommerceKickstartSlideshow extends CommerceKickstartMigration {
public function __construct() {
parent::__construct();
/**
* {@inheritdoc}
*/
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Import slideshow nodes.');
$this->softDependencies = array('CommerceKickstartPages');
......@@ -43,7 +49,13 @@ class CommerceKickstartSlideshow extends CommerceKickstartMigration {
$this->addFieldMapping('uid', 'uid')->defaultValue(1);
}
function csvcolumns() {
/**
* Returns CSV header mappings.
*
* @return mixed
* Array of mappings.
*/
public function csvcolumns() {
// "Title", "Headline", "Tagline", "Link", "Images"
$columns[0] = array('title', 'Title');
$columns[1] = array('headline', 'Headline');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment