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.
Comment | File | Size | Author |
---|---|---|---|
#5 | hash_plugin-1028216-5.patch | 1.09 KB | sdrycroft |
#3 | hash_plugin-1028216-3.patch | 1.07 KB | sdrycroft |
#1 | 1028216-fields-hash.patch | 1.21 KB | jeffschuler |
Comments
Comment #1
jeffschulerHere'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.
Comment #2
twistor CreditAttribution: twistor commentedThis 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.
Comment #3
sdrycroft CreditAttribution: sdrycroft commentedI'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.
Comment #4
twistor CreditAttribution: twistor commentedAdded.
6.x
http://drupalcode.org/project/feeds_tamper.git/commit/2750569
7.x
http://drupalcode.org/project/feeds_tamper.git/commit/c402a81
Comment #5
sdrycroft CreditAttribution: sdrycroft commentedApologies 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.
Comment #6
twistor CreditAttribution: twistor commentedSounds good to me, thanks!
http://drupalcode.org/project/feeds_tamper.git/commit/db6655a