2 seperate feeds updating the same set of nodes (feeds module) I'm using the feeds module to pull in a set of publications into a Drupal content type.  They are set to run at regular intervals using cron.  I have two separate feeds, which should work as follows:


Feed 1 (pure_feed) - pulls in the bulk of the fields
Feed 2 (harvard_format) - accesses a separate url source and updates one field on the content type.


The problem I have is that feed 2 always creates a new set of nodes rather than updating the existing nodes (that were created using feed 1).  I have used the debug options at /import and can see that the GUIDs for feed 2 match the GUIDs for feed 1, but it still creates 2 sets of nodes rather than updating the 1 set of nodes.

Here is an excerpt from the feeds_items database table:





As you can see they both have the same GUID but they are mapped to separate nodes.  Is there any way to have the second feed map to the same nodes as the first feed?
EDIT: there's a patch in this thread: https://www.drupal.org/node/1539224

I knocked something together that allows my second feed to update the nodes from my first feed. Not sure if this is the right way of doing things but it works. Here's what I did in case it helps someone else in future:


Created a custom processor that extends FeedsNodeProcessor
Copied across all of FeedsNodeProcessor's functions to the new class.
Overrided the existingEntityId function as follows (harvard_format is my secondary feed and pure_feed is my primary feed):


protected function existingEntityId(FeedsSource $source, FeedsParserResult $result) {

if($source-&gt;id == 'harvard_format') {

  $query = db_select('feeds_item')
    -&gt;fields('feeds_item', array('entity_id'))
    -&gt;condition('feed_nid', $source-&gt;feed_nid)
    -&gt;condition('entity_type', $this-&gt;entityType())
    -&gt;condition('id', 'pure_feed');

  // Iterate through all unique targets and test whether they do already
  // exist in the database.
  foreach ($this-&gt;uniqueTargets($source, $result) as $target =&gt; $value) {
    switch ($target) {
      case 'url':
        $entity_id = $query-&gt;condition('url', $value)-&gt;execute()-&gt;fetchField();
        break;
      case 'guid':
        $entity_id = $query-&gt;condition('guid', $value)-&gt;execute()-&gt;fetchField();
        break;
    }
    if (isset($entity_id)) {
      // Return with the content id found.
      return $entity_id;
    }
  }
  return 0;
}
elseif ($nid = parent::existingEntityId($source, $result)) {
  return $nid;
} else {

  // Iterate through all unique targets and test whether they do already
  // exist in the database.
  foreach ($this-&gt;uniqueTargets($source, $result) as $target =&gt; $value) {
    switch ($target) {
      case 'nid':
        $nid = db_query("SELECT nid FROM {node} WHERE nid = :nid", array(':nid' =&gt; $value))-&gt;fetchField();
        break;
      case 'title':
        $nid = db_query("SELECT nid FROM {node} WHERE title = :title AND type = :type", array(':title' =&gt; $value, ':type' =&gt; $this-&gt;config['content_type']))-&gt;fetchField();
        break;
      case 'feeds_source':
        if ($id = feeds_get_importer_id($this-&gt;config['content_type'])) {
          $nid = db_query("SELECT fs.feed_nid FROM {node} n JOIN {feeds_source} fs ON n.nid = fs.feed_nid WHERE fs.id = :id AND fs.source = :source", array(':id' =&gt; $id, ':source' =&gt; $value))-&gt;fetchField();
        }
        break;
    }
    if ($nid) {
      // Return with the first nid found.
      return $nid;
    }
  }
  return 0;
}


}   


Copied across the the Process and newItemInfo functions from FeedsProcessor.
Overrided newItemInfo as follows:


protected function newItemInfo($entity, $feed_nid, $hash = '') {

$entity-&gt;feeds_item = new stdClass();
$entity-&gt;feeds_item-&gt;entity_id = 0;
$entity-&gt;feeds_item-&gt;entity_type = $this-&gt;entityType();
// Specify the feed id, otherwise pure_feed's entries in the feeds_item table will be changed to harvard_format
$entity-&gt;feeds_item-&gt;id = ($this-&gt;id == "harvard_format") ? "pure_feed" : $this-&gt;id; 
$entity-&gt;feeds_item-&gt;feed_nid = $feed_nid;
$entity-&gt;feeds_item-&gt;imported = REQUEST_TIME;
$entity-&gt;feeds_item-&gt;hash = $hash;
$entity-&gt;feeds_item-&gt;url = '';
$entity-&gt;feeds_item-&gt;guid = '';


}