You can do this in your modules .install
file, using hook_update_N
. The script you need:
/**
* Updates all terms in 'vocabulary_name' vocabulary.
*
* Change the update number accordingly if you have previous updates already.
*/
function YOURMODULE_update_7100 {
$vocabulary = taxonomy_vocabulary_machine_name_load('vocabulary_name');
$terms = taxonomy_get_tree($vid$vocabulary->vid, 0, NULL, TRUE);
foreach ($terms as $term) {
taxonomy_term_save($term);
}
}
After that simply run your update script by calling update.php
or using drush:
drush updatedb
Method 2
If you don't want to use an update script, you can do it using drush php-eval
, as well. This is a one-line version of the above script:
drush php-eval '$v = taxonomy_vocabulary_machine_name_load("vocabulary_name"); $ts = taxonomy_get_tree($v->vid, 0, NULL, TRUE); foreach ($ts as $t) {taxonomy_term_save($t);}'