| Project: | Feeds |
| Version: | 7.x-2.0-alpha4 |
| Component: | Feeds Import |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (duplicate) |
Issue Summary
I'm trying to import 'nodes' from an older website that was designed by a terrible person.
The CSV i can make of the database this older website uses has the following structure:
guid;title;;;body;field_min;field_max;field_cat;field_subcat;field_cat;field_subcat;field_cat;field_subcat;field_url;field_email;field_adres;field_pc;field_plaats;field_provincie;field_tel;field_gsm;field_fax;field_foto;field_foto;field_foto;field_logo;field_provincieranking;
In this structure there are multiple fields called field_cat, field_subcat and field_foto.
I configured my importer to import field_cat (CSV) into the field_cat drupal field (it's a therm refrence field with unlimited values), and i expected all the values in the CSV would be added to the node as seperate values.
But what actually happens is only the last value is added to the node, i'd like to know how i can get all values in the CSV into the created nodes.
What i've tried:
- Renaming field_cat to field_cat1, field_cat2 and field_cat3 and targeting them all to teh field_cat in the drupal node.
- Using feed_tamper i've tried imploding and exploding in every combination
- Only having 1 field_cat in the header then importing, after importing changing to the next field_cat (so removing the first) so the nodes would be updated. But it just overrides the old value instead of adding the new value
- Search for issues like this one but i didn't understand/find any solution
I know this is probably working as it's designed (so no bug) but i'd like to know how i can solve my problem.
Comments
#1
This should do it for you.
All mappers should behave this way when possible. It's not possible for mappers with multiple columns. Fixing that would require an overhaul of how values are mapped. /soapbox
CSV import to Taxonomy tests pass.
#2
You will still need to rename the header to field_cat1, field_cat2 and field_cat3.
#3
This may sound noobish but how do i apply a .patch file?
#4
There's lots of documentation if you search "drupal apply patch". It depends a lot on your environment.
Alternatively, you can replace taxonomy.inc with the file below in modules/feeds/mappers.
#5
Thank you very much twistor the taxonomy patch worked perfectly (sorry for the late thank you but this was the first time i was able to try it).
But i'm still having the problem with the multiple photo's per node.
These photo's are imported into image fields so i'm guessing i need to edit some other mapper/*.inc file.
I'm looking through those files right now but if anyone on here knows what i need to edit that would be a great help.
#6
i have applied the patch but I still have the same result. The last field that is mapped is still being set as the default value.
For my specific implementation I am trying to map multiple values to a List (integer) using the checkbox widget. I have defined two items for my field in my taxonomy: item1 and item2. I also have my number of values that can be selected set to two.
In my mapper I have created two terms to be processed for the taxonomy import. source "item1" is mapped to target "List (integer) " and source "item2" is mapped to target "List (integer)"
If both "item1" and "item2" should be selected only the second item is after import...
Any thoughts on what I am missing?
#7
I think both should be targeted at item 1?
That's basically what i did, i have cat1, cat2 and cat3 all targeted at the category field
#8
Oops. That is how I set it up. I just described it incorrectly. I have updated my post.
Any other thoughts?
#9
Maybe post a screenshot of your imported file + your fields settings page for the nodes + mapper. Maybe i can see what is wrong.
I don't really get how an integer value is useful was a taxonomy therm. Maybe when i see it i'll get it.
#10
I think the problem is that I am trying to import taxonomy terms with list options instead of nodes with multiple taxonomy terms. I will dig into it further.
#11
I am using the category taxonomy as a navigation for an e-comm site. Depending on the url they arrive at I need to display different categories. You can see in the taxonomy-fields.jpg i have a Site Visibility "List(Integer)" field. I need to map the categories I import to the two options in that List.
You can see in the Taxonomy Term process image that I have source site and site2 both mapped to the Site Visiblilty Target. Only the second one gets mapped.
#12
The patch posted only fixxes problems with a Term reference field ( i think).
I don't know how to fix the problem for other types of fields.
If someone could post a patch for the integer field johandenooij is using and one for the Image field i'm using, we would both be very thankfull:)
#13
As far as I can tell the feed importer is setup to handle this. I just do not know the syntax for my csv file.
I need two values in the site column. What should this look like?
name,description,image,site,parent
cat1,great category,,0:1,cat parent
should it be 0:1,0/1
I have tried a few variations but nothing seems to work.
Maybe I can track it down in the code some where.
#14
Think you might wanna look at the Feeds tamperer plugin i think that can solve your problem
#15
This looks promising. Thanks.
#16
Feeds Tamper gave me the flexibility I was missing.
Thanks for the help @sterfpaul.
#17
@twistor, are you saying in #1 that it will likely never be possible to map multiple columns of a CSV to a multi-value field? Feeds and all its add-ons are fantastic, but the one thing I really miss from node_import was how easy it made multi-value mapping :(
#18
Marked #1315728: Having multiple values in a XML imported into one target value as duplicate of this, adding the image field in mappers/file.inc as a use case.
#19
use delimeter in csv "|" and delimeter for several image files "," (simple> "image1.jpg,image2.jpg,im3.bmp"). then open file
"\sites\all\modules\feeds\mappers\file.inc" and replace string #46 "$value = array($value);" on "$value = explode(',', $value);". This resolve very simple and allow import several values into one field.
#20
But this will only work if the values are in the same field in the source file. But for me this is not the case, i was hoping to import multiple source fields into one image target field.
Is there a patch for that?
#21
@sterfpaul, (you're coming from #1315728: Having multiple values in a XML imported into one target value )
Comment #19 is not the right one for you. Comment #1 should be a variant of your problem.
(oh, I see you already been in this issue, see #14...)
@sedoid #19 : your suggestion is relevant for mapping multiple values from 1 column to 1 multi-value field. Not for mapping multiple columns to 1 multiple field, as in this issue. BTW, setting the delimiter hardcoded is not the generic way to go. Until there is a Feeds UI for the delimiter, using Feeds Tamper is a better option, without hacking the module.
#22
@johnv #21
1. you can define several delimeter
2. yes hack module it is not good way, but sometime you must solve task quickly
3. drupal is open source and you can publish your resolve as patch (and so win...)
#23
hook_feeds_after_parse() gives us a chance to add a new value that we can map later when setting up the mappers in the admin area. Please read http://drupal.org/node/1360518.
#24
#982150: Multiple mappings to the same target
#25
#26
(Title corrected)
#27
Hi Twistor,
You patch works so good. Thanks a lot. If I also want to import multiple file values (in multiple columns) to one node field, how should I change the code? I tried to modify the file.inc file as your taxonomy.inc patch. But got nothing. Could you please help me figure that out? Thanks a lot!!!