I had a problem importing nodes and mapping them to their original NID from a D5 installation. I needed this to work for node referencing.
To fix the node ID problem I had to import the nodes via SQL and then running the import as a node replace. Also note that importing just the node table will result in broken nodes as it's missing the revisions. When you do import the nodes with their original NID and VID (Version ID) make sure you set the Auto Increment of that table to the highest VID in your node table. Then run the Feeds import and it should work fine.
I am not sure where this belongs but I hope it will help some people out there who are struggling with getting this to work.
Furthermore I think you should make people aware of that the GUID is a requirement. I had removed this and after several failed attempts realized it was causing the problem. I then mapped the GUID to the nid in my CSV file.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | feeds_save_nid-1046916-7.patch | 522 bytes | 13rac1 |
| #4 | feeds_save_nid-1046916-4.patch | 512 bytes | 13rac1 |
Comments
Comment #1
johnbarclay commentedI ran against this also. In the entitySave function in the FeedsNodeProcessor.inc when importing nodes with nids, it doesn't set the
$entity->is_newflag if the node doesn't exist. So thenode_save()function thinks its updating an existing node, but doesn't have a node version id and throws the error:Notice: Undefined property: stdClass::$vid in drupal_write_record()Its really an odd use case to be sending a nid into node_save but wanting to create a new node. But seems like a valid one when trying to preserve node relationships.
Adding
to the beginning of function entitySave($entity) takes care of the is_new flag, but I'm not sure if it correctly solves the problem or even works, yet.
Comment #2
dgastudio commentedsame problem here. subscribe
Comment #3
boztek commentedWhat are the restrictions on guid? Does it have to be in integer? If not are there any other restrictions on allowable strings? I am trying a unique string ID from a legacy system but the importer is not importing any nodes.
Comment #4
13rac1 commentedFeeds gives you a success message. There are no nodes created. So frustrating. I had many tables (node, node_revision, field_revision_field_*, field_data_field_*, feeds_item) to manually clean up after multiple failed imports, but finally after making this change my data import completed.
Patch is attached for code in #1. It works for me. Thanks!
Comment #5
anewcomb commentedI have the same problem. I find this in the "Recent log message" ...
Undefined property: stdClass::$vid in drupal_write_record() (line 6855 of /var/www/thesourceshow.new/includes/common.inc)
Adding the code in #1 above to FeedsNodeProcessor.inc fixed the issue for me.
Comment #6
dave reidPlease use !empty($entity->nid) rather than @$entity->nid. Also make sure the comment is a real sentence and put it above the additions rather than shoved off to the right.
Comment #7
13rac1 commentedGood point. My original patch was exactly as #1. This version is cleaned up.
Comment #8
johnbarclay commentedBumping to major because without this patch, importing nodes with nids in the mapper simply won't work, without any obvious error messaging. Its really not such an edge case since on a new site build/import you want to preserver node ids in the imported data. I wrote this for a friend who was tearing his hair out. The patch worked for him and I've used it on a couple projects since. (the one in #7).
Comment #9
e2thex commentedI have test this patch with the below list csv file.
Pre patch says items are import but do not get new nodes
post patch import works get new nodes, also can update nodes if nid already exist
Comment #10
e2thex commentedcommit to 7.x-2.x
http://drupalcode.org/project/feeds.git/commit/1a60aa1
Thanks for the Patch
Comment #11
ditcheva commentedPatch works for me. Thanks so much!
Comment #13
afagioliwith latest d7, you can create new nodes with node_save keeping original nid from previous drupal installations.
Comment #14
sidgrafix commentedWas having a GUID problem causing duplicate node creation with the same or duplicate GUID instead of updating the node when using feed import CSV to create and update nodes of a custom content type.
Looked to be an issue for many, wasn't sure where to post the results as I solved this in our situation. After having been dealing with this for several weeks, becoming increasingly frustrating - yet the answer was kinda simple!
In the basic settings we had set it to an import form we created in the "Attach to content type" drop down. Apparently this made it break however GUID should work (checked into the form couldn't figure out why it would cause this being it was a very basic content type) Title and body (originally intended for use as a means to track when we updated the feed)
Anyway long story short changed that to "Use standalone form" and our nodes updated based on GUID as they should. We only use GUID as the only unique field for this content importer because it's less of a headache to have to get the NID back and added to our CSV via spreadsheet for this particular case. " Now that it works as expected :) "
Just hope it helps someone else!
If there is a better place to have posted this please move it there!