I am currently working on a module to migrate a site's users and articles from D6 to D7.
Following the examples I have been successful with the Article migration right up to the body of the node. I've JOINed the D6 'node_revisions' table and have extracted both "body" and "teaser" from there:
$query->join(D6_DATABASE.'.node_revisions', 'nr', 'n.vid = nr.vid');
$query->addField('nr', 'body');
$query->addField('nr', 'teaser');Then the field mapping
$this->addFieldMapping('body', 'body');
correctly INSERTs the "body" value into the 'field_data_body.body_value' field in the D7 database. So it seems to me that the Migrate class (or at least the member function addFieldMapping()) clearly knows that 'body' actually means 'field_data_body.body_value' in the back-end.
How do I get the D6 'node_revisions.teaser' value into D7 'field_data_body.body_summary'?
Comments
Comment #1
nerdcore commentedThis works, but I am curious if there is a cleaner way to accomplish this:
Comment #2
mikeryanThis is much simpler:
This technique is covered in the migrate_example module bundled with migrate - see BeerNodeMigration in beer.inc.
Comment #3
nerdcore commentedHow about a node's taxonomy? I'm having a lot of trouble getting terms, which were migrated using Migrate and have their own map table, from D6 into D7.
Examples of field mappings has an example of imploded values:
And this is in reference to taxonomy terms, but I am unsure of how to load my terms from D6 into an imploded text string for use in this fashion. I thought this would work:
But that doesn't work. prepareRow() is definitely getting the correct info and creating the array as expected, but the field mapping simply doesn't happen (adding the field "region" to the stdClass "$row" doesn't seem to make it available for mapping in the constructor.
Also, the suggestion made on the Examples of field mappings page, as well as the WineMigration example are both specifying which vocabulary to use for terms. Is there a way this could be generalized so that terms of ANY vocabulary are mapped into the correct fields at the destination? I've edited my D7 content type to include fields for the four necessary vocabularies ("region" is one), but in writing a Migration I would like to make the code as general as possible for future re-use, so can we pull vocabulary machine_names from the DB instead of specifying? Ideally something very general like:
Comment #4
nerdcore commentedThe BeerNodeMigration uses the following:
So I had hoped I could use this to migrate terms of vocabulary "Region" into a 'field_region' field on D7:
The above code results in an empty field_region array on the imported node, instead of the region assigned to it on the D6 side.
Comment #5
nerdcore commentedThis is totally ugly but it works:
Comment #6
mikeryanNot that ugly (particularly if you remove the join() calls at the end, leaving them as arrays is just fine), that's the usual method for getting multiple-value related data into the source row.