Skip to content

Instantly share code, notes, and snippets.

@vinmassaro vinmassaro/news_migrate.migrate.inc Secret
Last active Feb 16, 2017

Embed
What would you like to do?
D6->D7 migration
<?php
/**
* Implements hook_migrate_api().
*/
function news_migrate_migrate_api() {
/**
* Declare the api version and migration group.
*/
$api = array(
'api' => 2,
'groups' => array(
'News' => array(
'title' => t('News'),
),
),
'migrations' => array(
'Article' => array(
'description' => t('Migration of articles from Drupal 6'),
'class_name' => 'NewsArticleMigration',
'group_name' => 'News',
'source_type' => 'article',
'destination_type' => 'archive_article',
'source_connection' => 'legacy',
'source_version' => 6,
'format_mappings' => array(3 => 'filtered_html'),
),
'Taxonomy' => array(
'class_name' => 'NewsTermMigration',
'description' => t('Migration of Topics terms from Drupal 6'),
'group_name' => 'News',
'source_vocabulary' => '1', // D6 Vocabulary ID
'destination_vocabulary' => 'archive_topics',
'source_connection' => 'legacy',
'source_version' => 6,
),
'User' => array(
'description' => t('Migration of users from Drupal 6'),
'class_name' => 'DrupalUser6Migration',
'group_name' => 'News',
'source_connection' => 'legacy',
'source_version' => 6,
)
),
);
return $api;
}
<?php
/**
* Common mappings for the Drupal 6 node migrations.
*/
class NewsArticleMigration extends DrupalNode6Migration {
public function __construct(array $arguments) {
// Add any other data we're pulling into the source row, before the parent
// constructor.
parent::__construct($arguments);
$this->addFieldMapping('field_link_to_external_story', 'field_external_link');
$this->addFieldMapping('field_alternate_title','field_secondary_title');
$this->addFieldMapping('field_archive_topics', '1')
->sourceMigration('Taxonomy');
$this->addFieldMapping('field_archive_topics:source_type')
->defaultValue('tid');
}
/**
* Implements Migration::prepareRow().
*/
public function prepareRow($row) {
drush_print_r($row);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.