For a situation where there are multiple migrations ("NewsItem", "Issue", "Person" based on D6 content type), and a content type "Video" has a nodereference field which could reference nodes for any of the first three types, how do we tell Migrate D2D to reference the correct migration?
Does this need to be handled per-row, or is it possible to say "Could be any of A, B, C"?
class MyD6VideoMigration extends MyD6Migration {
public function __construct(array $arguments) {
parent::__construct($arguments);
// Related Pages
$this->addFieldMapping('field_related_pages', 'field_related_pages')
->sourceMigration('Issue'); // Issue, or NewsItem, or Person?
}
}
Turned out for me that we had a single populated reference (Issue), so didn't need to solve this question today. Asking for some future soul's benefit :)
Comments
Comment #1
cthos commentedYou can actually specify the ->sourceMigration as an array, and it will loop through each of the Source Migrations until it finds a match.
So in your example it would be:
It will stop at the first migration it finds with a matching destination id and return that.
Comment #2
cthos commentedI've updated the migrate documentation (https://drupal.org/node/1133448) to reflect the information in this ticket.
Thanks!
Comment #3
xurizaemonMuch appreciated, cthos. Good to know.
Comment #5
josebc commentedThis functionality is working when using code for migration classes, however in the interface the source migration is a single value select instead of a multi, i have a migration for a lot of content types that worked perfectly from the UI except for this issue and would hate to have to re-write the whole migration in code just for this, is there a way to do that from the UI or will this require a patch?
Thank you for this great module