Pregunta

Estoy usando el migran módulo para copiar datos de varias fuentes para una nueva instalación de Drupal. Hasta ahora, soy capaz de reproducir una gran cantidad de lo que necesito de los ejemplos proporcionados con el módulo. Actualmente estoy atascado en la adición de términos o taxonomía a los nodos de nueva creación. El ejemplo muestra:

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

He rastreado por la correspondencia de destino migrate_example_beer_styles y parece ser el machine name para que la taxonomía.

He intentado imitar este comportamiento con cada variación de lo que debería ser mi machine_name, pero parece que nunca conseguir asociados los términos:

Por Identificación:

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

Y, por su nombre:

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

¿Estoy equivocado asumir la correspondencia de destino es la machine name de una taxonomía?

Esta versión de la migran módulo fue lanzado recientemente, no he encontrado algún otro ejemplo de votos la web.

¿Fue útil?

Solución

I'm currently working with migrate module myself, and I agree that the documentation is somewhat wanting at this point. :)

The 'machine name' of a vocabulary is listed in the Vocabulary table, in the field 'module'. Try using that value. Do note that you need to feed the text into the mapping, not the ids.

Otros consejos

This question still seems to be getting some views, so I thought I'd add what else I've discovered. While the accepted answer works, you are able to map Vocabs on ID:

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

->separator(',') used for passing a delimited string of source ids. Obviously, leave that off if you're mapping an array of values.

This is my first post on stackoverflow, so I apologize in advance if this isn't the accepted way to submit more information concerning this issue...

I've been stumbling around with the Migrate module for the past few days and was looking for a way to do this in Drupal 7. I had a comma-delimited list of taxonomy ids within an XML field that I wanted to use, but every example I found was retrieving from an external class, or from a database source.

Anyway, through trial and error, I found that you can use a field within the migrate class, rather than reference an external term migration class.

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

Check out the taxonomy csv import module at http://drupal.org/project/taxonomy_csv. It was easy to use and did what it was supposed to and more. I ended up only using the migrate module for importin gNodes and used this module for the taxonomy. It was a pleasure to use.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top