Provide a way to import and migrate from traditional taxonomy field
anrikun - June 8, 2009 - 16:32
| Project: | Content Taxonomy |
| Version: | 6.x-1.0-rc1 |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
I used to use the traditional taxonomy field to add taxonomy to my content.
Now that I want to migrate to Content Taxonomy, I need a way to import my taxonomy relations so far.
Is there a way to do it?
Thanks!

#1
+1
#2
I think this is a duplicate of #368918: Keep core taxonomy & CCK taxonomy synced
#3
A simple SQL to copy a trad taxonomy's data to a single value content_taxonomy field:
UPDATE content_type_TYPENAME AS ctrINNER JOIN term_node AS tn ON tn.vid = ctr.vid
INNER JOIN term_data AS td ON td.tid = tn.tid AND td.vid = VOCABULARY_ID
INNER JOIN node AS n ON n.vid = tn.vid AND n.type = 'TYPENAME'
SET ctr.field_FIELDNAME_value = tn.tid
Replace TYPENAME by the name of the content type containing the single value content_taxonomy field.
Replace VOCABULARY_ID by the the ID of the vocabulary linked to the content_taxonomy field.
Replace field_FIELDNAME by the name of the content_taxonomy field.
Don't use this SQL on a multiple value content_taxonomy field.
#4
Attached is a script that will let you import from core taxonomy into CCK content_taxonomy fields, both single- and multiple-valued. You do need to configure it manually by editing the code, hopefully the comments are clear enough =)
The script will spit back an SQL file. You can analyze the file to see if everything's correct, and then proceed to import it using MySQL.
Maybe this could become part of the main module?
PS: I'm available for freelance projects =)
#5
Nice initiative janusman. I had to correct the table name on line 110, but for the rest it saved me a ton of word.
Corrected version attached.
#6
Thanks a lot @janusman. Works flawlessly and saved me a ton of work.
#7
Is there a way to migrate values from cck taxonomy to traditional taxonomy .... i used the default option store in cck table only .. now i need it in the taxonomy as well ... is there a way or do i have to write my own upgrade script???
#8
@shady_gun:
That really should be a separate issue. Having said that, migrating from cck taxonomy to core taxonomy is easy: just enable "Save values additionally to the core taxonomy system" and then use a bulk operation that opens and saves all nodes.