How to add taxonomy terms using Drupal Migrate

I am using the migrate module to copy data from multiple sources to a new drupal installation. So far I can copy a lot of what I need from the examples presented in the module. I currently adhere to adding terms or taxonomy to newly created nodes. An example shows:

// These are related terms, which by default will be looked up by name $this->addFieldMapping('migrate_example_beer_styles', 'terms') ->separator(','); 

I tracked the destination mapping of migrate_example_beer_styles and it looks like this is the machine name for this taxonomy.

I tried to imitate this behavior with every variation of what my machine_name should have machine_name , but the terms do not seem to be related:

By id:

 // where source breed_id is '1,100' - it finds mapped values accordingly $this->addFieldMapping('breeds', 'breed_id') ->sourceMigration('BreedMigration') ->separator(',') 

And by name:

 // where source breeds is 'Dogs,German Shepherd' $this->addFieldMapping('breeds', 'breeds') ->separator(','); 

Am I mistaken in believing that the destination assignment is a machine name for a taxonomy?

This version of the migrate module was released recently, I did not find any other useful examples on the Internet.

+6
php drupal drupal-7 migrate
source share
4 answers

I am currently working with the migrate module, and I agree that at the moment the documentation is somewhat desirable. :)

The "machine name" of the dictionary is indicated in the dictionary table in the "module" field. Try using this value. Note that you need to pass the text to the mapping, not the identifiers.

+1
source share

This question still seems to get some views, so I thought I'd add what else I found. As long as the accepted answer works, you can map Vocabs to ID:

 $this->addFieldMapping('Exact Case Sensitive Vocab Name', 'source_field_name') ->sourceMigration('ExactSourceClassName') ->arguments(array('source_type' => 'tid')) ->separator(','); 

->separator(',') used to pass the separator string of source identifiers. Obviously leave this if you are matching an array of values.

+13
source share

This is my first stackoverflow post, so I apologize in advance if this is not an accepted way to provide further information on this issue ...

I talked with the Migrate module for several minutes and looked for a way to do this in Drupal 7. I had a comma-separated list of taxonomy identifiers in the XML field that I wanted to use, but every example I found was extracted from an external class or from a database source .

In any case, through trial and error, I found that you can use the field inside the migrate class, rather than refer to an external term migration class.

 $this->addFieldMapping('field_article_type', 'category_id') ->arguments(array('source_type' => 'tid')) ->xpath('/article/category_id') ->separator(','); 
+1
source share

Check out the csv taxonomy import module at http://drupal.org/project/taxonomy_csv . He was easy to use and did what he expected and much more. In the end, I used only the migration module for importin gNodes and used this module for taxonomy. It was a pleasure to use.

0
source share

All Articles