Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In migrating taxonomy terms, the key is mapping the legacy vocabulary to the destination vocabulary. Note that up till now we've dealt with classes that you will generally instantiate once - this is our first example of classes you would instantiate multiple times, one for each vocabulary to migrate.
- source_vocabulary: The unique identifier of the legacy vocabulary (a machine name in Drupal 7, or a vid for earlier Drupal versions).
- destination_vocabulary: The unique machine name of the destination vocabulary.
// In this example, we're consolidating two legacy vocabularies into one
$photo_term_arguments = $common_arguments + array(
'machine_name' => 'ExamplePhotoTerm',
'description' => t('Import Drupal 6 photo terms into media terms'),
'source_vocabulary' => '3', // "Photo category" vocabulary
'destination_vocabulary' => 'media_category',
);
Migration::registerMigration('DrupalTerm6Migration',
$photo_term_arguments['machine_name'], $photo_term_arguments);
$video_term_arguments = $common_arguments + array(
'machine_name' => 'ExampleVideoTerm',
'description' => t('Import Drupal 6 video terms into media terms'),
'source_vocabulary' => '5', // "Video category" vocabulary
'destination_vocabulary' => 'media_category',
);
Migration::registerMigration('DrupalTerm6Migration',
$video_term_arguments['machine_name'], $video_term_arguments);
For help with the Migrate UI and taxonomy migration, see also Advanced field mappings.
Comments
Mapping them to nodes
This works great to import the terms themselves (using 6.x-2.0-rc1), but mapping them to nodes seems to be a bit tricky. Here's the pattern I have seen to make this work, assuming that the vocabulary ID on the source Drupal 6 system was 1 (which it was):
Unfortunately it doesn't seem to work. Is this the correct pattern?
Thanks in advance,
Tom
Oops my mistake - it does
Oops my mistake - it does work! :) I had a bit of old data hanging around in my database that led me to believe otherwise.
D6 to D7?
Any hints or examples for a D6 to D7 migration? I'm having a hard time getting this to work.
Actually, this does work in
Actually, this does work in D7, except you don't need the sourceFieldList function at all.
Clarification
In the code above*:
The sourceMigration method is referring to the machine name of a term mapping that would have been defined in the hook_register_migrations. This took me some time to figure out.
So, my hook is defined as
The _vsc_migrate_627_coupon_conditions_terms is defined as:
So, you see where the machine name is defined ... right?
Then in my class VSCCoupon6Migration extends DrupalNode6Migration, we map it using:
Get it?
* Note, i am doing a 6 to 7 migration leaning on the awesome https://drupal.org/project/migrate_d2d ( not to say that Migrate ain't awesome either!)
Arguments in fieldmaping have been deprecated
The logic of this term mapping is correct
But this format has been deprecated. I just tried it to solve a term matching problem I was having in a D6 to D7 migration.
You can do this in the Migrate d2d UI:
When mapping term for node in UI, map the term AND include it's source migration (important!). Next, right under the term field source destination is Option: Set to 'tid' when the value is a source ID [term_field:source_type] You should put "tid" in the Default Value column.
Here is an example.
No class code needed for simple term migration to node
If all you are doing is moving a term inside a node in D6 to a term field in a D7 CCK field, then you can use the GUI. SomebodySysop is right. I really banged my head on this for a while. I hope this helps somebody.
This is what worked for me in my case.
DrupalTerm6Migration does not create new Vocabulary in destinati
Note that DrupalTerm6Migration in this example will not create the destination Vocabulary. Instead, you will get something like:
one for each source Term. Also,
drush mmsg [yourmigration]
shows something like:Manually creating empty Vocabulary placeholders at the destination allows the import to succeed as shown in the example.
--
http://drupaltees.com
80s themed Drupal T-Shirts
Hi, @Pearlbear,I need also
Hi, @Pearlbear,
I need also to migrate a vocabulary with term referenced node fields to convert from a D6 to a D7 site.
Can you may be give me a plan of action how to deal with this please?
I also try this through Migrat D-D but the taxonomy fields (node/term relation) do not get migrated....
Does anyone have reusable code for this? A plain (sub)module in .zip?
Thanks a lot in advance!
Greetings, Martijn
where to insert custom field mapping code?
Hi,
I'm new to Drupal and have performed a D5 to D7 migration and everything migrated over just fine except for forum content. I found this code here:
on a comment to this post here:
https://www.drupal.org/node/1609160
My question is, where in the migrate module should this code be inserted? Possibly in this include file here:
/modules/migrate/includes/field-mapping.inc
Or, somewhere else?
The errors I am receiving during the migration are:
for Nodeforum:
reset() expects parameter 1 to be array, null given File /forum.module, line 331
This is line 331 in forum.module:
$forum_terms[] = $term->tid;
and for Commentforum:
No node ID provided for comment
Thank you in advance. :)
Hi @johnvsc, and others
Hi @johnvsc, and others
May be not the right issue for this, but the issue is evolving to node term references as I see.
I would very much like to migrate my referenceD terms on my nodes from D6 to D7.
With the 'standard UI' and method it seems I only get one term reference per node.
Somehow node term references from a vocabulary with multiple values enabled. Like for a Hotel; wifi, 2 beds, bath etc..only one comes true.
Does your module help with this?
Are you willing to share your whole module here?
Thanks in advance for considering this.
EDIT: It works now. I forgot to set my term_reference field to "unlimited".
Greetings, Martijn
Try and read this series of
Try and read this series of articles - https://smbjorklund.no/how-migrate-content-drupal-6-7-using-migrated2d-p... it might help.
Stein Magne
http://smbjorklund.no
Content Taxonomy term fields
Just in case anyone else is needing this information, if you are migrating taxonomy terms on a node (in D6) that are put there by assign the taxonomy to the node, then the default mapping is used (put in constructor function in your migration code):
However, if the D6 field is a Content Taxonomy field, the D6_vocab_id should be the D6 field name instead. The rest of the code stays as above:
______________________________________________________________________________________________________