Update Taxonomy Terms code snippet
/* drupal taxonomy term conversion script by Agaric Design /
/ In some cases an older vocabulary may be replaced with a newer vocabulary. This script can help you replace terms from the older vocabulary with terms from the newer vocabulary. You'll have to create the association yourself, and put it in the form of an array as shown. /
/ keywords: convert category categories database vocab vocabulary terms
change taxonomy term tid
this might also be useful for splitting or merging vocabularies */
// Category - Old Taxonomy tid - New Taxonomy tid
// // Category name
// old => new,
$taxonomy_change = array(
// newsletter issue
// -- 2006-01
53 => 73,
// -- 2006-03
50 => 72,
// -- 2006-05
52 => 71,
// -- 2006-06
49 => 70,
// -- 2006-07
48 => 69,
// -- 2006-08
47 => 68,
// -- 2006-09
46 => 67,
// -- 2006-10
45 => 66,
// 2006-11
51 => 65,
// Newsletter Section
//-- Editor's Note
59 => 74,
// -- News
61 => 75,
// -- Other News
60 => 76,
// -- Event
43 => 77,
// -- Featured Article
37 => 78,
// -- Featured Org
41 => 79,
// -- Interview edit
40 => 80,
// -- Tips
42 => 81
);
foreach ($taxonomy_change as $old_tid => $new_tid)
{
$query = 'UPDATE {term_node} SET tid=' . $new_tid . ' WHERE tid=' . $old_tid;
$result = db_query($query);
if ($result) echo "Successful: $query
\n";
else echo "Failed: $query
\n";
// echo "Test: $query
\n";
}
/* drupal taxonomy term conversion script by Agaric Design /
/ In some cases an older vocabulary may be replaced with a newer vocabulary. This script can help you replace terms from the older vocabulary with terms from the newer vocabulary. You'll have to create the association yourself, and put it in the form of an array as shown. /
/ keywords: convert category categories database vocab vocabulary terms
change taxonomy term tid
this might also be useful for splitting or merging vocabularies */
// Category - Old Taxonomy tid - New Taxonomy tid
// // Category name
// old => new,
$taxonomy_change = array(
// newsletter issue
// -- 2006-01
53 => 73,
// -- 2006-03
50 => 72,
// -- 2006-05
52 => 71,
// -- 2006-06
49 => 70,
// -- 2006-07
48 => 69,
// -- 2006-08
47 => 68,
// -- 2006-09
46 => 67,
// -- 2006-10
45 => 66,
// 2006-11
51 => 65,
// Newsletter Section
//-- Editor's Note
59 => 74,
// -- News
61 => 75,
// -- Other News
60 => 76,
// -- Event
43 => 77,
// -- Featured Article
37 => 78,
// -- Featured Org
41 => 79,
// -- Interview edit
40 => 80,
// -- Tips
42 => 81
);
foreach ($taxonomy_change as $old_tid => $new_tid)
{
$query = 'UPDATE {term_node} SET tid=' . $new_tid . ' WHERE tid=' . $old_tid;
$result = db_query($query);
if ($result) echo "Successful: $query
\n";
else echo "Failed: $query
\n";
// echo "Test: $query
\n";
}
Comments
Post new comment