Closed (fixed)
Project:
Migrate
Version:
7.x-2.x-dev
Component:
Documentation
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
2 Mar 2011 at 09:24 UTC
Updated:
21 May 2012 at 09:53 UTC
Jump to comment: Most recent file
Comments
Comment #1
mikeryanAre you saying that you want each section of the incoming field to produce a term in a separate vocabulary? I.e., "family" would be a term in the "Relationships" vocabulary, "sports" in the "Hobbies" vocabulary, etc.? If so, that's something you'll need to implement yourself in a prepare() or prepareRow() method.
Comment #2
cesarseoane commentedHi mikeryan thanks for answer my question.
I'm going to try to be more specific.
I've a source table named products that has a field named context with information like "family/ sports/ cooking". This field is not related with other tables in the database, only with the "product" in which it appears.
I'd like to create a vocabulary "contexts" in which appears all the context of all the new products objects in drupal.
And create a multiple term reference field in product object in drupal with the context it has (one or more).
With separator, i can fill the context in products, but i don't know how to previously fill the vocabulary.
I was thinking to use a query to separate family, sports and cooking and get different registry for each one in the query, but i think it's not possible.
I need new ideas to solve the problem. Thanks
Comment #3
mikeryanOK, so the question you're asking is about creating the taxonomy terms themselves, not their assignments to each node. If it's not convenient to form a query to base an explicit term migration on, then what's needed is to 'lazily-create' the terms - as you hit term references during node migration, check if they already exist and if not create them. The Migrate module does not have this capability built-in, so you need to implement it yourself in a prepare method on your migration. It's pretty simple, I've done it a number of times - just do a db_select on taxonomy_term_date (not forgetting to include your vocabulary's vid as a condition), and either assign the returned tid if any, or do a taxonomy_term_save() to create the term and assign the tid from that.
It's not a bad idea to support an argument on MigrateTaxonomyTermReferenceFieldHandler telling it to automatically create the term if it's not found, let's make this issue a request for that feature (too late for Migrate 2.0, but a consideration for 2.1).
Comment #4
mikeryanComment #5
cesarseoane-at-gmail.com commentedMikeryan Thanks for your help with the process.
Comment #6
chromix commentedDid anything ever come of this? I'm running into a similar problem and I wasn't sure if this ever made its way into Migrate 2.1 or dev.
Comment #7
mikeryanNo one's been motivated enough to submit a patch so far, it seems.
Comment #8
klausiHere is a patch that supports a boolean 'create_term' argument. If set, unknown values will be created as new terms.
Usage:
Patch attached.
Comment #9
mikeryanCommitted, thanks!
Comment #10
klausiWhere do we document this?
Comment #11
mikeryanOK, documented at http://drupal.org/node/1224042.
Comment #13
chrisivens commentedAny chance of this for d6?
Comment #14
nlisgo commentedThanks for this lovely commit. Was the last piece in my migration puzzle!