Closed (fixed)
Project:
Feeds
Version:
6.x-1.0-beta4
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
30 Aug 2010 at 10:41 UTC
Updated:
20 Sep 2010 at 19:00 UTC
Jump to comment: Most recent file
Comments
Comment #1
alex_b commentedWhat you'll have to do is establish some existing property of your nodes as a unique identifier - what would that be in your case?
This could be a feature request, let's assume this is a support request for now.
Comment #2
stephenj commentedThanks for responding. I am not sure whether this was a support issue or a feature request. I have looked everywhere for anwers before I posted anything.
The safest information to use as a unique identifier in my case is the NID. The NID is easy to export. I do have other things like SKUs for some of my content type but NIDs are universal and always unique. As I mentioned I tried mapping the NID to the GUID but that didn't help.
Comment #3
alex_b commentedYou could create a mapping target 'nid' and make it optionally unique.
Comment #4
stephenj commentedalex_b: Thank you for the code!
I will attempt to do this and report back in a few days so that anyone following this thread can get this. I think my problem must be shared by others.
Comment #5
stephenj commentedOK - I have installed the patch and done a preliminary test with one record.
I exported a number of fields including the Title, NID and a CCK field using a Views Bonus pack Feed - CSV view.
I converted the CSV file into a Windows CSV file (I have found that format has normally worked best for instance in Node Import)
Then I created a Feed Importer with a CSV parser and mapped to the correct node type, mapping only the NID to Node ID as a unique value and the CCK field that I wanted to update.
I had "Update existing nodes (slower than replacing them)" checked with Default Format
I got this message:
user warning: Duplicate entry 'node-' for key 2 query: INSERT INTO path_redirect (source, redirect, query, fragment, language, type, last_used) VALUES ('node', 'hardware-old-style-stand-leg', '', '', '', 301, 1283301073) in /var/www/hotkilns_dev/includes/common.inc on line 3477.
It created a new node with a new node ID and added a "-0" to the end of the path name. The node is an updated version of the old node but the old node does exist.
Any suggestions?
Comment #6
stephenj commentedFurther comment from stephenj:
I noticed that the screen of the importer form (where you specify which importer to use) sent back a message as follows: "Updated 1 Parts node."
So the importer thinks it is updating the node - and in fact it is. However, probably because of the special nature of the NID is has to create a node when it does this.
It would be a trivial matter to create a computed CCK field, perhaps something that is automatically generated from the NID and maybe a date, that could be used as a unique value. I can understand that this could be dangerous for some users because it would be dependent on the user really understanding and making sure that the value is unique. Another thought would be to use the Path. I tried doing this with no luck earlier by mapping the Path to the URL in a Feeds Importer.
Comment #7
trevorbradley commentedSubscribe: I'm trying to do something quite similar. I've managed to apply the nid patch, and feeds claims to be updating nodes, but new nodes are being created.
EDIT: Just a bit of info for those people who were similarly confused as I was: The GUID and URL are terms brought over from RSS feed import. They don't have anything to do with your site's Drupal nid, or with the URL the page was loaded from.
Frustratingly, setting a GUID in uploaded CSV data works just great for duplicate entries. I'm pondering hacking the feeds system so that nodes exported to be edited in CSV have a GUID generated for them.
An alternative may be Ubercart, which also has a CSV importer. I think I like Feeds better so far though, even with the glitches.
Comment #8
stephenj commentedDoes anyone know of any system for exporting data as a csv file, updating it in Excel as a csv and then using that data to update? I was looking at some posts for Ubercart but I agree with TrevorBradley that Feeds seems to offer the best hope. I would consider using XML export/import (even though I am not familiar with it) if one would easily edit those files in mass like one can with a csv file. Node Import and Node_Import_Update do not seem like they are getting the attention that Feeds is getting.
The hopeful thing is that at least the node is being updated - even if it is then recreated as a new node.
Comment #9
trevorbradley commented@stephenj: Having a look around I think this is still the best bet. Let's see if we can figure out how to get unique nid import working.
I've been doing some debugging. I can verify that the nid is no longer set after this line is run:
$this->map($item, $node);
$this->nid is still fine just before this line is run...
More info as it comes...
EDIT: The fault is somewhere in FeedsProcessor.inc. These lines are unsetting nid...
Comment #10
trevorbradley commentedI think I found it...
Back to FeedsNodeProcessor.inc:
What's happening is that FeedsProcessor unmaps the nid, and then comes back to reset it (which is OK in theory). FeedsNodeProcessor comes back to re-set the nid, but the setTargetElement function is overwritten, and nid is ignored.
The following fix works...
I'll try to read up on patches and see if I can add one here.
Comment #11
trevorbradley commentedMy first patch! Hope it works... (You'll need to apply this to the original file, not the one you've already patched...)
Comment #12
trevorbradley commentedEDIT: Fixed the spacing in the array of names.
Comment #13
stephenj commentedThanks! I will give it a try and report back.
Comment #14
stephenj commentedI have tried RevorBradley's patch and I can report that it seems to be working fine.
I was learning how to install a patch and apparently this patch needs to be installed right int he directory where the file to patched is if that helps anyone else. It will not install from the Feeds directory.
Anyway I tested it out on an image field and a text field. On the text field I had html (some A refs) and that worked. The image field worked when I exported the whole path of the file plus of course the file name. I know there is more stuff int he array but I assume none of it is too important.
In any case I think this is a great success. I updated almost 300 records in about 1/2 hour including the time to populate and change the csv.
I change the format of the csv file that comes out of the Bonus Views Feed to a Windows CSV - (only because I have found with other importers like Node Import that that seems to work best. I'm not sure if it necessary with this and I have not tested that.
Now if I could only get the Node References and multi-value fields to export and import with Feeds....
Comment #15
alex_b commentedThat's because the patch is not rolled right - trevor, check out http://drupal.org/patch
Here's a re roll, will commit asap.
Comment #16
alex_b commentedCommitted, thank you.
http://drupal.org/cvs?commit=416056
Comment #17
stephenj commentedalex_b:
Thank you for helping with this. Quick question: should I reinstall the patch?
Comment #18
alex_b commentedreinstall the patch?