I'm importing items that don't have GUIDs. On import, I want to ignore the item if an identical item has ever been imported previously, and create a new node if no existing identical one exists.

I've come up with a workaround to accomplish this that calculates a hash over all of an item's yet-processed source results, and stores it in the $variables[] array as a sort of special replacement variable. (I'll attach the patch in a comment.) I then map this variable as the feed item's GUID.

I'm sure there are much better ways to do this, and would appreciate advice in that direction. It looks like Feeds has its own built-in item hashing, but it's not obvious to me how to use that to identify and act on uniqueness vs. duplicates, and it appears that feed items require a single, uniquely-identifying field.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jeffschuler’s picture

Status: Active » Needs review
FileSize
1.21 KB

Here's my workaround solution, which calculates a hash over all of an item's yet-processed source results, and stores it in the $variables[] array as "$all_fields_hash" -- as a sort of special replacement variable.

twistor’s picture

Project: Feeds XPath Parser » Feeds Tamper
Version: 6.x-1.10 » 6.x-1.x-dev
Assigned: Unassigned » twistor
Status: Needs review » Needs work

This makes more sense as a Feeds Tamper plugin so that it can be used as across multiple importers. It could actually be a Feeds patch easily too. Hmm... Great idea though.

sdrycroft’s picture

FileSize
1.07 KB

I've created a simple plugin that, I believe, does what has been requested. The plugin should only really be used with the GUID field (is it possible to restrict a plugin to specific fields?). If a GUID is set, then this plugin does nothing, if a GUID is not set, then the GUID is set based on an MD5 hash of the import row.

twistor’s picture

sdrycroft’s picture

Status: Fixed » Needs review
FileSize
1.09 KB

Apologies for reopening this issue, but I've made a small change to the file/patch to add a setting. This will enable users to specify whether or not to overwrite a value set for a field, meaning that already set GUIDs will be kept.

twistor’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.