Migrate/Migrated2d: Linking Migrated Nodes to Non-migrated Terms
How to link migrated Drupal nodes to non-migrated taxonomy terms using prepareRow() and complete() hooks.
Migrate and Migrate d2d modules expose a powerful API to developers who have the task to migrate a part or an entire website to Drupal 7.
The approach:
- Identifying unmigrated terms that are mapped to the node
- Unlinking the node and the terms before the node migration
- Saving the IDs of the terms in a static variable
- Relinking the node and the terms right after persisting the node
Note that prepareRow() and complete() belong to the migration base classes; prepareRow() is called very early in the process before importing each node and complete() is called right after persisting each node.
public function prepareRow($row) {
if (parent::prepareRow($row) === FALSE) {
return FALSE;
}
// remove unmigrated tags from $row
$row = $this->rm_unmigrated_terms(...);
}
function complete($node, stdClass $row) {
// linking node to unmigrated terms in target
$this->linking_stories_to_unmigrated_terms(...);
}
For more information regarding the migrate/migrated2d API, click here.