0

I have set up a periodic feed importer in drupal which imports nodes and updates existing nodes.

Lets assume the imported xml consits of two fields: the title and a long text field.

I import the nodes in the morning with the following content:

title   long text field
1       long text 1
2       long text 2
3       long text 3

So three nodes were correctly created with the two fields. But if I import later and the content of the xml has changed to the following:

title   long text field
1       long text 1
2       
3       long text 3

As you can see the long text field of the second node is empty, but feeds doesn't update the field. The value after reimport is still 'long text 2'.

I haven't found an option or a module to achieve this. I have tried to manipulate the input data via

hook_feeds_after_parse(FeedsSource $source, FeedsParserResult $result) {
  // replace empty results with ' ' (one space), so they gets replaced
  for ($i=0; $i < sizeof($result->items); $i++) { 
    for ($o=0; $o < sizeof($result->items[$i]); $o++) { 
      if (empty($result->items[$i]['xpathparser:'.$o])) {
        $result->items[$i]['xpathparser:'.$o] = ' ';
      }
    }
  }
}

But feeds only jumps into the function if it detects changes in the xml, but i think empty fields don't get considered.

2
  • I fear I don't really understand your question? I have used feeds myself and it works as you describe: If the field is empty in the updated xml, the new import will also update the node's field and empty it. Or? Sep 23, 2014 at 13:37
  • no, in my project feeds doesn´t empty the field :(
    – dba
    Sep 23, 2014 at 13:45

1 Answer 1

2

Yes, this is a known problem of feeds. However, there is a patch for it and will be included in the next release as I know. You can already apply the patch now yourself:https: www.drupal.org/node/1107522 It is #161 in the link above.

I am using it for a while and tested it too, it works for your scenario above. There is one problem with email and URL fields: Feeds still creates the field when the import is empty and this results in empty fields shown.

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.