migrate

MigrateDestinationCommerceProduct

The contrib module Commerce Migrate provides a few destination classes that extend the Entity API destination class provided by Migrate Extras.

When declaring the destination map, use "commerce_product" as the entity type (which is defined by the Commerce module suite), and "my_product_type" as the bundle type.

The following class imports commerce products. "sku" and "commerce_price" mappings are relevant to products. In the following example, "my_product_type" is the machine name of the commerce product type (defined via UI config), "import_database" is the import database name (defined in settings.php), and "import_data" is the table in that database where the import data exists. In the source map, "ItemNumber" is the unique identifier column in the table.

<?php
class AseEndoMigration extends Migration {
/**
* Doc comment.
*/
public function __construct() {
parent::__construct();

// The defintion of the columns.
$columns = array(
'Category',
'Name',
'ItemNumber',
'Description',
'USRetailPrice',
);

// Entity type, and bundle.
$this->destination = new MigrateDestinationCommerceProduct('commerce_product', 'my_product_type');

// Select all endodontic products.

Read more

Migrate taxonomy images from Drupal 5

The following class was used to migrate taxonomy term images from Drupal 5's Taxonomy Image module into a proper Drupal 7 entity field. You'll want to adjust class and field names appropriately for your use case.

Note: Taxonomy Image in Drupal 5 did not make use of the files table, so you need to specify a path to your taxonomy images in the prepareRow() method.

<?php
class GWJTermImageMigration extends DrupalTerm5Migration {

public function __construct(array $arguments) {
$this->sourceFields['field_image'] = t('Constructed source image field');
$this->sourceFields['field_image:title'] = t('Constructed source image title field');
$this->sourceFields['field_image:alt'] = t('Constructed source image alt field');
$this->sourceFields['field_image:source_dir'] = t('Constructed source image source directory field');
$this->sourceFields['field_image:destination_dir'] = t('Constructed source image destination directory field');
$this->sourceFields['field_image:destination_file'] = t('Constructed source image destination file field');
parent::__construct($arguments);

$this->addFieldMapping('field_image', 'field_image');
$this->addFieldMapping('field_image:file_class')->defaultValue('MigrateFileUri');
$this->addFieldMapping('field_image:title', 'field_image:title')->defaultValue('');

Read more

Cookbook

A cookbook of tips and ideas for Drupal-to-Drupal Migrations. See sub-pages for recipes.

Migrating to Drupal 7

Cover image for this book
Sub-title: 
Learn how to quickly and efficiently migrate content into Drupal 7 from a variety of sources including Drupal 6 using automated migration and import processes.
Authors: 

Trevor James

Publisher: 
Packt Publishing
Publication date: 
2012-12
Page count: 
158
ISBN-13: 
9781782160540

Upgrade from 6.x or 7.x-1.x to 7.x-2.x

Database Issues

If your database has a hyphen(-) in it, please make sure #1926418: OG Migrate fails if database name contains hyphen is resolved before reporting any new issues.

Setup

In order to upgrade Organic Groups from Drupal 6 or from OG 7.x-1.x to 7.x-2.x, the following modules must be installed and enabled:

Execution

Once the required modules have been enabled

  1. Make a backup of both your files and database.
  2. Download the latest version of OG 7.x-2.x (this can done via drush or ftp).
  3. Run update.php. If you're unsure what this means, go to the following URL and follow the instructions:
    http://yoursite.com/update.php
    After running the update script, you may get the message "The content access permissions need to be rebuilt. Rebuild permissions." Wait to rebuild permissions until after running the migrate scripts.
  4. Navigate to:
    http://yoursite.com/admin/content/migrate
  5. You should see the migrates that are still pending:
Read more

Adding serialized data to users data column

The users table has a "data" column which can store serialized data, but you cannot migrate into this field by doing a mapping, because the user migration doesn't provide the "data" field as a possible mapping destination.

Instead, you can add the serialized data in your migration by implementing the prepare() method, which operates on the created entity:

<?php
public function prepare(stdClass $account, stdClass $row) {
 
$account->data = array(
    
'field1' => $row->1,
    
'field2' => $row->2
 
);
}
?>

(This information comes from cameronbprince at this issue. I have confirmed that it works.)

Subscribe with RSS Syndicate content