Problem/Motivation
The latest dev of Feeds (August 27, 2014) supports unique target in mappers (now that patch #195 of #661606: Support unique targets in mappers has been committed), but it would need another module to handle the unique field value validation.
The Field validation module already has integration code for this feature (see field_validation.feeds.inc), but that is based on an older patch from #661606: Support unique targets in mappers. Specifically, the parameters for the unique callback were changed to line them up with similar callback functions in Feeds. As such, the implementation in Field validation is outdated.
Proposed resolution
Update the Field validation's implementation.
Comment | File | Size | Author |
---|---|---|---|
#18 | field_validation-feeds-unique-target-1705386-18.patch | 3.65 KB | MegaChriz |
#5 | field_validation.feeds_.zip | 985 bytes | g089h515r806 |
Comments
Comment #1
scottrigbyChanging issue title for clarity
Comment #2
scottrigbyThere is a linked patch ready for review
Comment #3
g089h515r806 CreditAttribution: g089h515r806 commentedUnique target in mappers is very usefull when import/update content using views.
Comment #4
agileadamThe patches in #661606-87: Support unique targets in mappers worked great for me. I see there are now later version of those two patches. I'm going to do some comparing to see what's different.
Once this is all sorted out, someone should update http://drupal.org/node/1307732 to add some documentation about using Field Validation to enable the "Unique" option within feeds.
Comment #5
g089h515r806 CreditAttribution: g089h515r806 commentedHere is the code that works with patch "feeds-unique-target-661606-115.patch",
unzip it and copy "field_validation.feeds.inc" file into your field validation directory.
Comment #6
g089h515r806 CreditAttribution: g089h515r806 commentedI have commit the code of #5.
I also need this feature.
Need to apply patch http://drupal.org/node/661606#comment-6481214 to make it work.
Comment #8
Jason Dean CreditAttribution: Jason Dean commentedHi
I was using field_validation.feeds.inc from #5 and the Feeds patch in #6 and everything was working fine.
Then I upgraded Feeds to latest 7.x-2.0-alpha7 and reapplied the patch in #6
Now in the importer mappings, it looks like the 'unique target' column has been changed and I can no longer select my validated field :(
Comment #9
g089h515r806 CreditAttribution: g089h515r806 commentedFor feeds alpha7, we need to increase the weight of field validation in system table.
I have committed some code to updte the weight value in install file.
Comment #10
zeezhao CreditAttribution: zeezhao commentedI tried latest dev version and got this error while trying to edit a field previously set up:
Comment #11
g089h515r806 CreditAttribution: g089h515r806 commentedfield_validation_date_validator is a new validator, has not been not full tested.
But i test it on a text field, it works.
Comment #12
2phaCan someone give me a point in the right direction on how to get this field validation working with Feeds 7.x-2.0-alpha7.
I have been trying to get unique checks in feeds all day. I have been scouring the issues related to this in the Feeds module, but most of the issues are getting a little out of control.
I have a feeds imported (from csv) to import but I can't use the GUID because some content has been added before through the interface. So I want to use one of the fields as unique.
I have installed the fields validation module and my validation rule works fine when creating content (content is not created if field is not unique within the bundle).
Now I need it to work with feeds. After installing this module, should I be able to select the field (the one with the validation rule) as unique in the feeds importer? Because I can't.
Comment #13
2phaOk, I've worked out why I was not seeing a make unique checkbox on my feeds importer mapper. It is because the field validation rule is on a product reference field (supplied by commerce module).
The problem is that in field_validation_feeds_processor_targets_alter, $rule->field_name is used to set the field unique, but the index on the $targets array for the product reference field has either ':sku' or ':product_id' appended to the end of the field name.
Comment #14
2phaI got it working..
I thought I should post my code here in case it helps someone in the future.
I had to add this to the existingEntityId function in FeedsProcessor.inc in the Feeds module:
I then changed the functions in field_validation.feeds.inc to:
In the above code I have hard coded the name of my product reference field 'field_product'.
Again, I'm not sure if this is really the right place to post this, but I felt I needed to post it somewhere as I'm pretty sure someone else will face this issue at some point.
Comment #15
emilyf CreditAttribution: emilyf commentedI got this working through the method I put in #139 here: http://drupal.org/node/661606#comment-7574929
Comment #16
emilyf CreditAttribution: emilyf commentedNote that this did not work with the dev branch but it did with 7.x-2.3
Comment #17
jmev CreditAttribution: jmev commentedemilyf, I'm not sure I followed your post clearly, but are you saying it would work to just bypass suggestions on this page and follow steps in your post?
Comment #17.0
jmev CreditAttribution: jmev commentedUpdated issue summary.
Comment #18
MegaChriz CreditAttribution: MegaChriz commentedA fix for unique target in mappers has finally been committed to Feeds! However, the Field validation module's implementation for this feature in Feeds is based on an older patch. Specifically, the parameters for the unique callback were changed to line them up with similar callback functions in Feeds. As such, the implementation in Field validation is outdated.
Patch attached. This is the same patch as in #661606-195: Support unique targets in mappers.
Comment #19
ar-jan CreditAttribution: ar-jan commentedI have tested fields_validation with the patch in #18 (in combination with feeds 7.x-2.0-alpha8+46-dev (2014-Aug-29)) and can confirm that the patch works.
Tested with a CSV import to node, using a text field configured to be Unique per bundle.
Also note the docs by MegaChriz.
Thanks, +1.
Comment #20
Leeteq CreditAttribution: Leeteq commentedComment #21
aegirone CreditAttribution: aegirone commented#18 is ok . I have test this problem , all is ok ............
Comment #22
g089h515r806 CreditAttribution: g089h515r806 commentedcommited.