Skip to content

Instantly share code, notes, and snippets.

@oxyc
Created April 17, 2012 10:09
Show Gist options
  • Select an option

  • Save oxyc/2405072 to your computer and use it in GitHub Desktop.

Select an option

Save oxyc/2405072 to your computer and use it in GitHub Desktop.
#!/usr/bin/env drush
$terms = array(
27 => 318,
28 => 319,
29 => 320
);
foreach ($terms as $src => $dst) {
$nids = taxonomy_select_nodes($src, FALSE, FALSE);
$process = array();
foreach ($nids as $nid) {
$translations = translation_node_get_translations($nid);
foreach ($translations as $translation) {
$process[] = $translation->nid;
print $translation->nid . "\n";
}
}
$nodes = node_load_multiple($process);
foreach ($nodes as $node) {
$update = new stdClass();
$update->nid = $node->nid;
$update->type = $node->type;
$update->field_erikoisruokavalio = $node->field_erikoisruokavalio;
$update->field_ominaisuudet = $node->field_ominaisuudet;
foreach ($node->field_ominaisuudet as $lang => $values) {
foreach ($values as $idx =>$value) {
$update->field_erikoisruokavalio[$lang][] = array(
'tid' => $dst
);
unset($update->field_ominaisuudet[$lang][$idx]);
}
}
field_attach_presave('node', $update);
field_attach_update('node', $update);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment