My CSV import fails to update existing nodes identified by concatenated data I passed into the unique GUID target field. Please point out my mistake or suggestions for making updates work.

I was importing a CSV file to create nodes of an existing content type. I would like to update existing nodes upon import. The titles are not unique, and the Feeds fields 'Title' and 'GUID' are the only two target fields for which I can choose 'Unique.'

To create a unique ID, I had to use Field Tamper to concatenate two fields, 'Column 1' and 'Column 2'. I did that by setting the target of 'Column 2' to GUID, setting GUID to be unique, and setting the tamper to concatenate the two fields. (Concatenating those two fields elsewhere does work just fine.) I had already set the Node Processor settings to 'Update existing nodes.'

The nodes were correctly created by this import, but subsequent imports created duplicates instead of updating the existing nodes.

If it matters, other nodes of the same content type were created through a user interface.

How can I change this importer to update existing nodes, please?

Comments

MichaelGreisman’s picture

Title: Import did not update nodes with concatenated value as GUID » GUID field not working to update nodes; am I using it wrong?

Sorry for prodding, but I'm hoping that an edit to my title might result in some more interest in the ticket.

I decided against link-baiting it, e.g. "See 3 ways to import updates; 1 way to fail!"

I doubt this is a failure of the built-in GUID field; this is most likely a step I'm missing in making it work. I've seen some suggestions that other modules are needed (such as Field Validation), but I didn't want to make additions that would seriously effect the rest of the large project in order to solve this one issue.

megachriz’s picture

Status: Active » Postponed (maintainer needs more info)

I can not reproduce your issue (I tested with the latest dev). Note that only nodes imported with Feeds have a GUID. Manually created nodes do not have them. GUID's are saved in the feeds_item table.

MichaelGreisman’s picture

It's not really a reproducible issue. So... I was trying to import some user-friendly text into GUID, which wouldn't have helped me anyway if I were trying to import updates to manually-created nodes.

Is there any other way to import updates to manually-created nodes (as well as Feeds-imported nodes), besides using the Title as the unique identifier? Otherwise I have to do edits to the content type and existing data in order to use the Title for the identifier instead of for the content's actual title (which can't be guaranteed to be unique).

thanks!

megachriz’s picture

Status: Postponed (maintainer needs more info) » Fixed

Yes, there is another way to update nodes using another unique identifier.

  1. First, apply the (latest) patch from #661606: Support unique targets in mappers to Feeds.
  2. You then have two options:
    • Field validation module
      1. Install the Field validation module.
      2. Patch it with the patch for Field validation also provided in #661606: Support unique targets in mappers (at the time of writing this patch is called "field_validation-feeds-unique-target-661606-95-do-not-test.patch").
      3. Go to "Manage fields" page of your content type.
      4. Click on "validate" for the field you want to be the unique identifier.
      5. Add a validation rule of type "Unique values".
      6. Go to the mapping settings of your Feeds importer and select the field as your unique target.
    • Own solution
      1. Implement hook_feeds_processor_targets_alter() in a custom module.
      2. For the target you want to make unique, set optional_unique to TRUE.
      3. Also, for the same target, specify a callback function that looks up the node using the unique identifier in unique_callbacks.
      4. Implement the callback function.
      5. Go to the mapping settings of your Feeds importer and select the target as your unique target.

      See (after having applied the patch from #661606) feeds.api.php for further information and examples. Look specific to the examples for hook_feeds_processor_targets_alter() and for my_module_mapper_unique.

I hope this answers your question. If not, feel free reopen.

Status: Fixed » Closed (fixed)

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

brandonc503’s picture

*deleted as i cant remove account