It would seem appropriate to allow for field mapping from Source Data to destination node on import.
My example: I have to import a large user base from CSV, user import works great but I have related data unique to each user: Address, City, State, Zip, Phone, Etc... It would be useful to be able to map additional data to fields when importing.
Ideally it would work as importing users from CSV followed by adding additional import functions and choosing where the function will dump its data from a select list of fields.
Ex: Mapping Source Label: Zip | Target: field_zip(Profile)/field_zip(Location)
and I would be able select field_zip(Profile) as its the appropriate field even though I use a duplicate field in the Location Content Type.
Comments
Comment #1
uwe_a CreditAttribution: uwe_a commentedwhy not just create two feeds importers, one for profiles and one for locations ??
Comment #2
johnvI do not really understand your problem:
Do you want one source-field to be imported in 2 target fields? You can add the same field twice in the mapper
Mapping Source 1 Label: Zip | Target: field_zip(Profile)
Mapping Source 2 Label: Zip | Target: field_zip(Location)
Is your Location data not showing in the mapper (I suppose you have Location attached to your Profile Content Type)?
Use this module for mapping: http://drupal.org/project/location_feeds, see issue 'Location_feeds for Drupal 7';
Comment #3
kpastore CreditAttribution: kpastore commentedI agree this is an issue. You cannot add fields to users using feeds. Only the bare minimum is allowed. This needs to be addressed if Feeds is to take the place of other modules in D7, such as node import, that did not have this issue.
To answer uwe above, you can only import a feed to a content type. Using Profile2 for extra user fields, one cannot import a feed to this since it is not a content type. This is a serious need as there are many websites with unique user information that cannot be imported into D7 now.
Comment #4
johnvSo this only applies to users? Changing title..
Comment #5
wusel CreditAttribution: wusel commented@#3:
This is the same problem as in
#1228062: Feeds integration.
How to import Profile2-fields for new users from one CSV-file?
Thanks in advance
Comment #6
Martin P. CreditAttribution: Martin P. commentedIs there a resolution meanwhile? I have the same problem.
I have many additional fields für the Users, which i created as hidden fields (users should not edit the values manually). So I have to import the additional Values
AND
i have to import the user role! that are the two most important aspects. Maybe this helps:
http://drupalcontrib.org/api/drupal/contributions!feeds!plugins!FeedsUse...
?? If anybody knows how to add my additional fields and the user role field as target for the feed user importer - please contact me :)
Comment #7
wusel CreditAttribution: wusel commentedMy solution you can find at http://drupal.org/node/1285276 ("Import new users and their Profile2 fields from one CSV file") using the module migrate.
But you have to change the code you find on that cookbook-page!
Good luck!
Comment #8
Martin P. CreditAttribution: Martin P. commentedI think that wont be my way ^^ You did a good job by creating this tutorial. But i want to find a way to change the mapping and add targets on the Feeds Module. I thin this would be much more comfortable. Besides i dont want to install thousands of Modules für one Task. I think i will check how to add the fields to feeds user targets :)
Comment #9
Martin P. CreditAttribution: Martin P. commentedMaybe this could help:
What is 'field_some_custom_field' ? Where do i find, what name i have to write there? I want to add custom hidden fields as targets for Feeds Module (to import users automatically one time a day).
Maybe somebody can help me how to add this function in the FeedsUserProcessor.inc.php
I have found out, that you have to add 2 parts of code for every target you want to add. I have found the code for Adding User Roles for example:
and
I also know, that the first part is to use / work with the the input (but i dont know where it gets saved) and the second part is for naming and describing the target for the backend UI. But i am not good enough to use this knowledge for adding other/additional user fields.
Maybe somebody could make an example?
Comment #10
Martin P. CreditAttribution: Martin P. commentedI got the solution for this problem!
First: All Profile Fields i added were normal fields or hidden fields (Field Hidden-Module). I added them in the Account Configuration.
To add all the additional profile fields to the feeds user import you have to edit the "./sites/all/modules/feeds/plugins/FeedsUserProcessor.inc" file. Somerewhere you will find this code:
Lets call this code (A) and somewhere you will find this code:
lets call it (B).
For every Field you want to add as Target for the Feeds User Importer you have to add the following:
After (A)
[PLACEHOLDERNAME] could be something like city or maybe gender and [FIELDNAME] is the real name of the field you added in accountconfiguration (mostly: field_name) like field_gender.
Thats the first part. And additional you have to put another part IN (B)
Part (A) should now look like this:
and Part (B) should look like this (have a look at the commas after every part):
The last step (after you put in all the field you want to) you have to add
at the end of A. So the Solution could looke like this:
(A):
(B):
Have fun :)
Comment #11
firfin CreditAttribution: firfin commentedNice work on figuring all that out Martin.
However, you do realize you have written a tutorial on hacking the feeds module, right? Every update of the module will erase your code and you may also get unexpected issues. See Do not hack core most of this page also applies to contrib modules.
A better approach is to try and create a patch for feeds or write a module for this. I think hook_feeds_processor_targets_alter() and a accompanying callback in feeds.api.php is your best bet for what you are trying to achieve.
Also see The developer's guide to Feeds especially the section on the mapping API.
Keep up the good work. ;-)
Comment #12
Martin P. CreditAttribution: Martin P. commentedI dont got the time to solve these problem :( In my apprenticeship i have to find fast ways to solve those problems. Most time I am working with another cms (webEdition), which is much more simple and gives me a lot of posibilities too. In my apprenticeship I dont have any time to learn more about own modules or something like that :( So but I see the problem. For now this solution has to suffice.
Comment #13
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedI might not be sure what this issue is about, but as of today you can map to additional fields on the user account. For Profile2 support, see #1228062: Feeds integration.. As an alternative, you could also try the Feeds entity processor module.