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

nath - June 11, 2009 - 16:03

+1

#2

janusman - July 6, 2009 - 16:50

#3

anrikun - July 23, 2009 - 12:32

A simple SQL to copy a trad taxonomy's data to a single value content_taxonomy field:

UPDATE content_type_TYPENAME AS ctr
INNER 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

janusman - July 24, 2009 - 13:51

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 =)

AttachmentSize
import_content_taxonomy.php.txt 5.95 KB

#5

Sutharsan - August 21, 2009 - 14:44

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.

AttachmentSize
import_content_taxonomy_1.php_.txt 5.8 KB

#6

omo - September 23, 2009 - 08:26

Thanks a lot @janusman. Works flawlessly and saved me a ton of work.

#7

shady_gun - November 10, 2009 - 05:21

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

Bodo Maass - November 11, 2009 - 10:35

@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.

 
 

Drupal is a registered trademark of Dries Buytaert.