4

I am using D7, Feeds, XPath Parser. For mapping, I need to use a custom field as the unique field. I am retreiving data from booking.com and the unique value their is the hotel id, so i need to save this hotel id from the user as well as retrieve data from booking.com bsed on this unique field and map to my contents based on this unique field.

In the documentation of feeds i found this - Use field other than nid as unique node field in feeds for 7.x-2.x

It says you need to apply a patch from this comment - http://drupal.org/node/661606#comment-5921904

This patch applies to a file called field.inc in the mappers folder of feeds. However this file is not even present there. The patch also applies to another file, however running the patch gives errors.

  • Is field.inc actually present in feeds/mappers?
  • Am I making some mistake in applying the patch?
  • Is there any other way of achieving - custom field as unique field for mapping?

Any help on this would be greatly appreciated. Thank you.

9

This tutorial works for me:

How to configure unique fields in Drupal feeds importer ?

See also the official documentation, which states that you can either use the Field Validation module, or write a custom solution implementing hook_feeds_processor_targets_alter().

  • 1
    This should be the accepted answer now. Since Feeds 7.x-2.0-beta1 no patches are needed anymore. – marcvangend Nov 1 '15 at 22:52
  • 1
    First link is incorrect – Dimetry Jul 3 '17 at 6:34
4

If you will only be using one Feeds importer (i.e. only importing from a single XML source), you can do this without applying any patches. In the importer mappings, just map the hotel ID field to GUID and set it as unique. If you need to use hotel ID in your content type, map it to another field as well.

From your description, it sounds like your needs might be more complex (i.e. importing from multiple sources into the same content type)? If so, you can use Field Validation module to set your field as unique. Note that last time I used it, this also required a patch - but it may be committed now. This Field Validation issue provides some more info.

I think the method you referred to (using Unique Field module) is a little outdated now.

  • Thanks for the answer. However I was able to get my requirement fulfilled from another patch and using field validation module. I haven't tried your method yet though it looks like it could have worked too :) Thank a lot! – SGhosh Dec 18 '12 at 9:36
2

Answering my own question -

Using patch from - http://drupal.org/node/661606#comment-6481214 on the feeds module and a patch from - http://drupal.org/node/1705386#comment-6481224.

Hence using Feeds with Field Validation. First a validation for unique must be added to the required field. In the mapping for just like title can be set as unique even this field will have the setting to be set as unique.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.