I have used feeds to import some nodes with taxonomy term reference.

The source XML is the following one.

    <title>Test 1</title>
    <body>Test body 1</body>

First import is OK. I edited <term>My_term_bar</term>, and started importing a second feed. After the second time, the node has both "My_term_foo" and "My_term_bar," but I need only "My_term_bar" from the second import.

Is there any hook_feeds_node_item_presave() I can use to alter the values being imported?


My final code of hook_nodeapi inpired by sel_space:

switch ($op) {
      case 'presave':
        if ($old_node = node_load($node->nid)) {
          $taxonomy = array_diff_assoc((array) $node->taxonomy, (array) $old_node->taxonomy);
          if (!empty($taxonomy)) {
            $node->taxonomy = $taxonomy;

1 Answer 1


If data needs to be modified before it is saved use this module : Feeds tamper

For advanced modification use hook_nodeapi in drupal 6 with the insert parameter , with hook_nodeapi load the old node like this :

$old_node = node_load(node->nid);
$node->taxonomy = array_diff($old_node->taxonomy,$node->taxonomy)

So now you are sure that the $node contain only the new value , Hope this will help

  • Thanks for answer. I know feeds tamper, but it only change source. And if I try use hook_nodeapi then in node->taxonomy are both terms My_term_foo and My_term_bar and I dont know which is from second import.
    – kubedan
    Apr 15, 2012 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.