Closed (outdated)
Project:
Feeds
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
29 Jun 2010 at 16:10 UTC
Updated:
16 Jun 2016 at 22:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
alex_b commentedThis patch introduces a $reset flag that can be used to reset a field at the beginning of mapping to a node.
This is similar to the approach that alevine suggested in #753426-33: Partial update of nodes.
Comment #2
andrewlevine commentedSubscribe. In theory this definitely works. But are people really targeting multiple times?
Comment #3
alex_b commentedExpanding on the approach. There is a fundamental conceptual problem:
- #1 resets on callback called first time, which won't work as we need to throw up the reset flag for each target.
- The attached patch resets on target called first time, which doesn't work because a target can contain subtargets (that's the reason why link tests won't complete on this patch).
Comment #4
alex_b commentedThis is a state based approach as suggested by andrewlevine on #753426. It circumvents the limitations of a reset flag based approach as in #3.
Tests are completing. What I am not happy about in the state based approach is that it is not entirely intuitive because only in the corner case of a node loaded and mapped it is important to use the double tracking with $state. And then, we only need $state because we can't tell whether a node comes fresh from loading or whether we have already executed a mapping operation on it.
Comment #5
alex_b commentedRE: #4, maybe I could make a more elegant and clear use of the state variable.
Comment #6
andrewlevine commentedWhat do you think about this approach? It assumes that target items are nodes (or at least objects where the target element is $target_item->$mapping['target']). To work with #753426: Partial update of nodes I removed all of the changes to the mappers from that patch.
All tests passed.
Comment #7
andrewlevine commentedTested with the unchanged filefield.inc mapper and it worked as expected (overwrote the file field instead of adding multiple photos)
Comment #8
alex_b commented#6 I've been there :-).
Same problem as in #3: targets can contain subtargets. Tests are passing because we actually don't have any tests asserting that we don't aggregate on fields that have been imported earlier...
Comment #9
andrewlevine commented@alex_b - #8
But in #6 we are clearing out the fields after the call to map() but before any mapping is actually done. So all the fields are cleared out initially and then aren't cleared out for the whole duration the mapping is occurring, so targets/subtargets can be aggregated throughout the loop.
So I think #6 works unless you are talking about saving state across multiple map() calls in which case I don't understand why the $state approach in #4 would work.
Comment #10
alex_b commentedThe problem is that mappers like link use a mapping target key like "field_link_fieldname:url" and field_link_fieldname:title" - thus #6 is not able to successfully unset the fields.
Comment #11
andrewlevine commentedGot it...will keep thinking on a solution
Comment #12
andrewlevine commentedThis patch builds on #6 but allows a new optional 'target_key' property which will allow mappers that created subtargets to specify the actual target_key since there is no way of knowing it otherwise. I stepped through the mapping of a link field and it seemed to work fine.
All tests passed
Comment #13
alex_b commented#12 - I think this is the best approach so far.
A. $target_item can be an array or an object.
B. The new key needs documentation in feeds.api.php
C. I'd rather call it 'real_target' instead of 'target_key' similar to Views' 'real_field' key.
Comment #14
alex_b commentedComment #15
andrewlevine commentedImproving the patch to meet the requirements of comment #13.
All tests passed except 8 from "Defaults: fast feed" but I think that might have been from unrelated changes?
Comment #16
andrewlevine commentedTurns out it was me that broke the fast feed tests. The fact that we were unsetting timestamp before mapping broke the processor. I changed the setting of the timestamp after map had run and everything works. I looked through the current processors and this problem should not occur elsewhere.
Now all tests are passing
Comment #17
alex_b commentedThis is looking great. I did some minor adjustments to comments:
A. Mandate to declare real_target when key in $target[key] does correspond to $node->key.
B. State underlying reason for unsetting fields before mapping.
All tests passing. RTBC?
Comment #18
alex_b commentedCommitted. Thank you.
http://drupal.org/cvs?commit=389844
Comment #19
alex_b commentedandrewlevine, FYI: #853194: Mapping: don't reset all targets
Comment #20
Anonymous (not verified) commentedI'm using 1.0-beta3 but can't get this to work...
I'm importing a .csv file that has 'phone1' and 'phone2' fields/columns.
I'd like these to map to my multi-valued 'Phone' CCK field, but 'phone2' is overwriting 'phone1' in the first instance of my 'Phone' CCK field.
Am I doing something wrong, misinterpreting this functionality, or is this still a bug?
Comment #21
andrewlevine commentedBWPanda, that is the intention of the feature. Are you sure your CCK field is a multiple value field (set in the field configuration settings)
Comment #22
Anonymous (not verified) commentedYep, 'Number of values: Unlimited'...
What is? The overwriting, or the ability to add multiple columns to the same multi-valued field?
Comment #23
andrewlevine commentedThe ability to add multiple items to a multi value field is the intention. If you can, you should look in mappers/content.inc to see exactly what's happening. Would help to debug if you open a new issue and post a feed example, mapper config and content type export.
Comment #24
alex_b commented#20, the issue at hand is unrelated to your request. Please open a new issue.
Comment #25
Anonymous (not verified) commentedCreated new issue here: #873198: Import multiple values to tag vocabulary
Comment #26
Anonymous (not verified) commentedI don't see how #20 and #0 are different. We are talking about "Support using same mapping target multiple times". And that is what #20 is also talking about.
Comment #28
nicolash commentedI'm trying to map multiple sources to a multi-value CCK field...and also thought that #20 was about the same. The new issue in #25 deals with taxonomy, so is not the same. Apologies if there's a more appropriate issue, if so, pls point it out.
I've tried this with beta-10 and DEV, but all that gets saved is the last mapped item, as reported above.
I've attached content type and feed config as a feature, as well as the CSV file. I'm happy to investigate this myself in more detail as soon as I've confirmed that I'm not missing something obvious.
Comment #29
nicolash commentedI've found more hints that this should just work, except it doesn't.
http://drupal.org/node/860748#comment-3258186 (see follow up comments)
Comment #30
nicolash commentedThis is probably way too simplistic, but currently this works for me with initial tests of multi-value text fields...
Change:
to
Comment #31
ypahnu commentedI tryed all that I can to do this..i mapped
xpathparser:128 Extras Text
as a Parse XML using XPath.
On the view from drupal 1 that do the xml feed I add field extra and selected Group multiple values ( 2 start from 0 ). But when I go to the XMLfeed it show
The most wierd is that Images with multyple values work fine.
I need help to solve this, or I will need to change alot on the website and separate and limit the text fields. (probably since I can't understand what is doind those divs,, maybe it's something about $view->style plugin->rendered )
Comment #32
ben.hamelinI've spent a few hours on this, both yesterday and this morning, before adding my two cents.
I wanted to be sure I had followed the updates of this version, and checked the patches to ensure I wasn't missing something.
So, here's where I'm at.
After downloading -beta10, and configuring a simple CSV source with multiple source fields for one single multi-value CCK field, I was also unable to get multiple values populated.
As suggested in #23, I added some debugging to the /mappers/content.inc file to review what was happening.
I came to the same conclusion as Nicolas in #30. Altering the code in a similar fashion gave me the desired results.
Questions, specific to the content_feeds_set_target() method (as in #30):
1) $value is the string from the source feed, when would it be an array?
2) more importantly, it is the $field value that we wish to identify as a multi-dimensional array
So, as a follow up, is there ever a case where $value WOULD be an array, that I (we) are missing?
Otherwise, I think this update is appropriate.
Comment #33
nicolash commentedLike Ben, I still think I'm missing something and have the same questions, but here's a patch FWIW. I've been running this successfully in production sites, but it has the potential to break things that I may not be using.
Comment #34
mpaler commentedI wonder if you wouldn't mind telling me how you are formatting your csv file for multi values?
I tried your patch with the following CSV with Node Processor settings set to Update existing nodes:
When I import, value 2 still overwrites value 1.
(FWIW, I'm using multi checkboxes)
Comment #35
nicolash commentedThe multiple values must be *per item*, like this:
I guess the overwriting behaviour in your example should be as it is, since you could otherwise never update any nodes. Also, not sure whether this was your intention, but mapping to a node id would be bad...I used that as the GUID set to unique.
I've attached my test importer for this as well for reference.
Comment #36
nicolash commentedOh, and I haven't really looked at checkboxes yet....this is for a plain text field...
Comment #37
kenorb commentedComment #39
twistor commented