I have a use case in a D6->D7 migration (using migrate_d2d), where I need to split terms from a large vocabulary into two new vocabularies in the D7 site. I achieved the splitting into two new vocabularies just fine in the taxonomy migration (see here for details on how), but the problem is getting the new mapping to work during the blog node migration so that the nodes are attached to the proper vocabulary field in the destination node.
So here's the setup:
- People and Organizations (vid 4)
- People and Organizations (field_people_organizations, vid 9)
- Journalists (field_journalists, vid 5) Non-Journalists
- Non-Journalists (field_non_journalists, vid 7)
In my blog node class constructor, I've added this:
$this->addFieldMapping('field_people_organizations', 4) ->sourceMigration('PeopleOrganizations'); $this->addFieldMapping('field_people_organizations:source_type')->defaultValue('tid'); $this->addFieldMapping('field_journalists', 4) ->sourceMigration('PeopleOrganizations'); $this->addFieldMapping('field_journalists:source_type')->defaultValue('tid'); $this->addFieldMapping('field_non_journalists', 4) ->sourceMigration('PeopleOrganizations'); $this->addFieldMapping('field_non_journalists:source_type')->defaultValue('tid');
However, what this does is just populate all three taxonomy reference fields with all terms from the People and Organizations field in the source. For instance, if the D6 People and Organizations field has Term A, Term B, and Term C, and in D7, Term B should be in Journalists and Term C should be in Non_Journalists, I get all three terms in each term reference field instead of Term A in field_people_organizations, Term B in field_journalists, and Term C in field_non_journalists.
I did a query that joined the D6 db with the D7 db using the migrate_map_peopleorganizations table in the D7 site, and the terms themselves are correctly populated in the D7 tables, so I know that's not the issue. I suppose I could do some wrangling in prepare() to move the terms to the appropriate field in the blog node, but it seems there should be an easier way to map to the new vocabulary. I'm guessing I would create a field on the fly and map to it in prepareRow(), but I'm not sure what I would put in that field, since the second parameter in addFieldMapping() for taxonomy terms is the source vocabulary, and there is no source vocabulary for the new ones.