Hallo,

I want to import a CSV-file with new users. The CSV-file shall also import some "Profile2"-fields for each user in the same line.

How can i choose the "Profile2"-fields?

My modules:
Chaos tools 7.x-1.0-beta1
Entity API 7.x-1.0-beta10
Feeds 7.x-2.0-alpha4
Feeds Admin UI 7.x-2.0-alpha4
Feeds Import 7.x-2.0-alpha4
Job Scheduler 7.x-2.x-dev
Profile2 7.x-1.0-beta4
Profile2 pages 7.x-1.0-beta4

Please help me.

Thanks

Comments

wusel’s picture

Component: Code » Miscellaneous
wusel’s picture

I want to explain my wish:

On the page "Mapping for User processor" I can only add Targets from the normal core-Profile-fields.
But I want to add fields from the "Profile2"-fields.
Then I would be able to import new users with normal fields AND "Profile2"-fields in one step out of one CSV-file.

Where can I connect the "Profile2"-fields to the CSV-Importer?
Can I get the code I have to add in what file of a new module?

Thanks in advance

bjlewis2’s picture

This would be fantastic! I will soon be importing hundreds of users to a site, and would REALLY like to be able to import Profile2 info at the same time!

CraigSander’s picture

Priority: Normal » Major

Is there a way to do this without directly accessing the SQL database?

wusel’s picture

@CraigSander:

I want to import the CSV-file directly from the user interface.

wusel’s picture

Version: 7.x-2.0-alpha4 » 7.x-2.x-dev
Component: Miscellaneous » Code

I change the Component to 'Code' and updated the Version to '7.x-2.x-dev (2011-Aug-14)'.

webadpro’s picture

Has this been fixed yet or not?

wusel’s picture

Despite my update to the module-version 7.x-2.x-dev on my site, I can not find a "Profile2"-field on the page "Mapping for User processor".

ellocin’s picture

StatusFileSize
new20 KB

Hello,

I've followed this thread for one month and perhaps a piece of my work could help someone. I've written a Profile2Processor to import fields. (see the code attached). I'm new in drupal/php world, so all advices are welcomed!

regards,

wusel’s picture

Thank you very much.

I use Drupal 7.8 (all drupal-module are up-to-date).
After I enabled your module, I have build a new feeds-importer, there I selected the 'Feeds Profile2 Processor'.
Then I have selected 'Update existing profiles (slower than replacing them)' (your comment in line 9 of feeds_profile2_processor.inc).

When I click on 'Mapping', I get a white screen only with the text 'Fatal error: Call to undefined function dsm() in C:\xampplite\htdocs\abt\sites\all\modules\feeds_profile2_processor\feeds_profile2_processor.inc on line 221'.

Something is wrong with 'dsm()'. My drupal does not know this function.

So I add an '//' in the beginning of line 221 of feeds_profile2_processor.inc and clear the drupal-cache.
Now I can click on 'Mapping' to choose the fields.

I will test your 'Feeds Profile2 Processor' this weekend and update this comment or add a new one as soon as possible.

ellocin’s picture

sorry for this,

I forgot to remove the dsm (from devel module) function calls...

regards,

johnbarclay’s picture

Here is another approach: Use the generic entity processor #1033202: [Meta] Generic entity processor patch, since profile2 users are entities as suggested in #1135450: Importing users to Profile2.

I have not tried this, but it seems like a more sustainable path since the profile 2 patch doesn't belong in the feeds project and the profile2 module already marked such a feed mapper.

wusel’s picture

@ellocin:

I had to add another '//' in the beginning of line 77 of feeds_profile2_processor.inc.
I connect the 'Owner name' with the same field of the user in my CSV-file, then your module works very fine.

Thank you very much for this great module.

Do you want to publish this as well? Or the maintainers?

wusel’s picture

Category: support » feature

@maintainers:

My CSV-file cannot contain the UID of the user, since the UID arises from Drupal when creating the user by the (first) Feeds User-import. So it is not possible to connect the Profile2-fields to the account during the second Feeds Profile2-import by using 'Entity processor Profile type' as definend by #1033202: [Meta] Generic entity processor-#54.

Please complete this module with the code in #9 ('Feeds Profile2 Processor').

Many thanks in advance.

wusel’s picture

Status: Active » Reviewed & tested by the community
ellocin’s picture

@wusel

no problem to publish this module but I don't know how to do that (from dashboard??)....I'm going to search into drupal.org.

regards,

awasson’s picture

Subscribing... This seems like a pretty obvious must have feature for Profile2. I'm giving the module that ellocin provided on #9 and it seems like it should work. I'll have a look at the patch as well.

drnikki’s picture

The code in #9, with a few modifications, works fine for initial user & profile2 creation, but fails on updating existing users, even with unique target provided. I'm working on a solution for this, but wondering (hoping!) that someone beat me to it.

ambientdrup’s picture

The code in #9 does not seem to be working for me. I've created 2 fields using Profile2. Then I've installed this feeds_profile2 processor module and cloned my User importer. When I configure the importer to use the feeds_profile2 processor it's not letting me choose the 2 fields I've added in my mapping. I also get the following error:

Notice: Trying to get property of non-object in FeedsProfileProcessor->getMappingTargets() (line 191 of /Applications/MAMP/htdocs/www/sites/all/modules/feeds_profile2_processor/feeds_profile2_processor.inc).

Suggestions?

-Trevor

ambientdrup’s picture

You can ignore my request in #19. I realize it's working with the dev version of the Feeds module. I installed the Dev version and now I see the mapping ... and the error disappeared too.

-Trevor

ambientdrup’s picture

Ok so I'm running into some additional issues with the module in #9:

1) I can import users with the generic User Import importer via Feeds module. I set the id = GUID as the unique key.

2) I then verify that I have created 9 users on the site via the importer

3) I create 2 profile fields using Profile2 module and verify that these show up as fields on the user accounts

4) I run an import using this custom feedsprofileprocessor module. I map the first and last name fields that I've set up in my profile2 to those 2 fields in my imported CSV file

5) Running the import says that the profiles have been imported

6) But when I view the user account the first and last name fields are still empty. So the data is not getting mapped to the correct accounts.

Also I did set up the unique id to be the unique target for both of the importers (user and profile).

What am I missing here?

-Trevor

dave reid’s picture

Status: Reviewed & tested by the community » Active

No patch here to commit.

mukesh.agarwal17’s picture

Status: Needs review » Active
StatusFileSize
new4.84 KB

I've been struggling with the same thing for quite some time. However, I'm not using the profile2 module and instead have my custom entity which is related to the user. I came up with the idea of allowing multiple types of entities to be imported at the same time. So, when you are importing user entity, it would be great, if I can import my profile (another type of entity) as well. So, what I did is the following:

  1. Provide an option with every import to attach multiple entity types to be imported along with the current import.
  2. This would mean that when a user U1 is imported, another type of entity P1 also gets created alongside. As in my case, the patch assumes that you handle the code for inserting a P1 on inserting a U1 in your custom modules. Like profile2 module adds profile fields in user add/edit forms. However, profile2 module is not using my proposed implementation to create/update profile entity on creating/updating users. (See http://drupal.org/node/1394900)
  3. After applying this patch, you'll see all the entities listed as checkboxes on all the feed structures -> processor settings (for e.g. in your User Import - localhost/MYPROJECT/admin/structure/feeds/edit/user/settings/FeedsUserProcessor)
  4. Select the entities that you want to associate your base import with and save
  5. Now, in mapping page, you'll see all the properties and fields of the attached entity in mapping
  6. Select the ones you want to import and then save and you are done. Start importing

Attached is the patch. Please share your observation.

P.S. : I thought of writing a separate module first, and was half way through when I realized that this is more of a generic requirement and therefore created a patch to modify the base processor class. Will be great if the owner of the module can accept the patch.

bjlewis2’s picture

Assigned: Unassigned » mukesh.agarwal17
Status: Active » Needs review

Marking as "needs review" so that others know there is something here to test.

mukesh.agarwal17’s picture

Status: Active » Needs review
StatusFileSize
new1.87 KB

Corrected patch - the previous one does not do an is_array check before starting the for loop. Please provide feedback if you are able to test.

Anonymous’s picture

I also get the error message "Notice: Trying to get property of non-object in FeedsProfileProcessor->getMappingTargets() " on Drupal 7.10.

However I'm using the latest dev (2012-Jan-07) of Feeds doesn't fix it like it did for the person in #19.

Any ideas there? I might have to try the generic entity importer if this doesn't work.

mukesh.agarwal17’s picture

The way I expect this to work for profiles is using FeedsUserProcessor. Anyways, can you please share the line number in which the error shows. You can find that in your php error log as well.

Anonymous’s picture

Sorry, I was actually referring to the module provided in #9. I'm going to try your patch next.

Anonymous’s picture

Just noticed the second patch #25 is a lot shorter than #23. Is it complete?

mukesh.agarwal17’s picture

StatusFileSize
new4.92 KB

Thanks for pointing out, it was a silly mistake from my end when submitting the patch. The final one is attached here.

Note: This patch will not be applicable to profile import, unless the profile module changes its implementation of attaching the profile to user add/update (using hooks) instead of doing it only on form submissions. (See http://drupal.org/node/1394900)

Anonymous’s picture

Thanks. I successfully implemented the patch, however I get the following error message after going to the "Mapping" page. Under the user processor settings I have "Profile" checked.

Warning: Illegal offset type in isset or empty in EntityDrupalWrapper->spotBundleInfo() (line 676 of /Applications/MAMP/htdocs/vma/sites/all/modules/entity/includes/entity.wrapper.inc).

mukesh.agarwal17’s picture

The error seems to be with bundles. I'll write a new patch providing the options to select bundles as well.

mukesh.agarwal17’s picture

StatusFileSize
new5.38 KB

Uploading the new patch which works with entities + bundles. The problem with the previous patch was that I was not taking into account different types of bundles associated with each entity.

Hopefully, this one should work.

mukesh.agarwal17’s picture

StatusFileSize
new5.89 KB

Aahh, my bad.. Just saw the link to the patch and it was not complete. Please use the one attached here.

Anonymous’s picture

Fantastic, thanks - the patch works and I now have access to map Profile 2 fields through the Mapping section of a User Processor feed.

I ran through a test scenario with a single data row in a CSV file for an import. The user was imported successfully but unfortunately the profile fields are empty. I'm pretty sure I set up the mapping correctly - it's a few simple fields like "Name" and "Title".

What could I be missing?

mukesh.agarwal17’s picture

Not really, the current implementation of profile is not supported with this patch. They update the profile of a user only via forms which I believe is not the best implementation. (See http://drupal.org/node/1394900). We will have to wait until profile2 module updates its implementation.

Anonymous’s picture

I just found this - an in depth explanation of how to import Profile 2 fields into users - http://drupal.org/node/1285276

I haven't tested yet but it looks good.

wusel’s picture

@afestein(#37):

The page of your link shows, how to import Profile 2 fields into users using "Migrate". This issue is, how to import Profile 2 fields into users using "Feeds".
That is different.

Anonymous’s picture

Understood, but it's still worth mentioning in this topic for the benefit of others. After a couple of days of hair pulling it's the only solution I found that has worked for me so I thought I'd mention it.

Ale.bcn’s picture

Hi mukesh.agarwal17 all the group:

trying to apply the patch i got:

# patch < feeds_generic_entity_import_v5.patch
patching file FeedsProcessor.inc
Hunk #1 FAILED at 419.
Hunk #2 FAILED at 454.
Hunk #3 FAILED at 475.
Hunk #4 FAILED at 487.
Hunk #5 FAILED at 501.
5 out of 5 hunks FAILED -- saving rejects to file FeedsProcessor.inc.rej

any ideas?

k_zoltan’s picture

#40 Ale.bcn try patching the alpha-4 version, not the dev version. That worked for me.

TJM’s picture

Hi K_Zoltan,
I haven't been successful importing profiles from Drupal 6 (csv file) into profile2 Drupal 7.12 with the feeds module (with patch). I was wondering what settings you used for Processor. What field did you use for the unique field?
All of my modules are up-to-date as of today. Also, My list of users has already been updated via upgrading Drupal 6 to 7. So, all I need to do is to add the profiles to already existing users.
Thanks,
Ted

Anonymous’s picture

Thanks for your nice little module! After commenting the call to dsm() in feeds_profile2_processor.inc , i am able to list the fields that I want to import using feeds import. :)

jainparidhi’s picture

Hello everyone,

Could someone guide me how to accomplish this? I am confused with all the different patches and the modules.

In order to import users and their Profile2 fields into Drupal 7 from a csv file using Feeds, I need to install the Feeds module (dev release or the alpha V4 release?) and then install module from comment #9 above, and then use the "feeds_generic_entity_import_v5.patch" from comment #34 above? Am I correct?

What will the "feeds_generic_entity_import_v5.patch" patch? The original feeds module, or the module from #9?

Any help is appreciated! Thank you in advance.

PJ

Anonymous’s picture

I tried to import from a csv file, and I'm absolutely sure the source attributes are correct since I could import data on the user account. But profile2 fields are not set (I verified in the database).

I run Feeds version 7.x-2.0-alpha5+38-dev, and Profile2 version 7.x-1.2. I also applied the v5 patch from #34.

Maybe I missed something in the configuration?

liquidcms’s picture

patch in #34 appears in the UI to add support for profile2 fields; but it breaks being able to set any of the fields as the unique fields

liquidcms’s picture

and the values don't import.. but the UI is right.. :)

wickwood’s picture

I've applied the patch in #34 to the 7.x-2.0-alpha5 version of the feeds module and then merged that into the current 7.x-2.x-dev version.

I was able to map all the fields to the User and Profile2 fields I had created but upon trying to import I get this error:
Fatal Error: Call to undefined method stdClass::setuser() in /path-to-my-site/modules/entity/includes/entity.property.inc on line 428

Anybody have any ideas how to fix this?

Thanks for any help in advance!
Steve

mattheweigand’s picture

So the UI is right but none of the patches actually work? That is disappointing, because my client has asked for this functionality 2 days before the project deadline. I guess I'll have to keep searching for another solution.

ariran’s picture

something does not work :(

I established modules: FEEDs and FEEDS_SQL
after that i installed feeds_profile2_processor.tar_.gz and made feeds_generic_entity_import_v5.patch

in settings of Import i use SQL fetcher, SQL parser and User processor (becouse if i use Feeds Profile2 Processor, Mapping does'not work)
http://clip2net.com/s/2U3DI
after making Mapping for User processor i strat Import process and see User name missing or email not valid.

what problem can it be?

rosso69’s picture

I used the patch from #34 and i get a list with all entity's. The only problem is that i cannot save the setting.
It unchecked everything.

moonray’s picture

Assigned: mukesh.agarwal17 » Unassigned
StatusFileSize
new6.04 KB

I've taken a different approach that seemed more in line with how feeds has been doing things: I've added a new feeds parser to handle profile2 entities.

To import:
1) import your users using the user feeds parser.
2) import your profiles using the new profile2 feeds parser. Make sure specify either a uid, user name, or user email to link the profile to the user.

The patch can perhaps use better defaults for the parser config, and maybe some additional validation, but otherwise it works well.

Status: Needs review » Needs work

The last submitted patch, feeds-profile2_integration-1228062-52.patch, failed testing.

moonray’s picture

Status: Needs work » Needs review
StatusFileSize
new7.04 KB

OK, let's actually do that with the latest dev. Also fixed some notices.

EDIT: it probably still needs some tests.

Status: Needs review » Needs work

The last submitted patch, feeds-profile2_integration-1228062-54.patch, failed testing.

moonray’s picture

Status: Needs work » Needs review
StatusFileSize
new6.25 KB

And it would help if I ACTUALLY uploaded a patch that works with the latest version, instead of the same one.

Status: Needs review » Needs work

The last submitted patch, feeds-profile2_integration-1228062-56.patch, failed testing.

moonray’s picture

Status: Needs work » Needs review
StatusFileSize
new5.9 KB

Now with proper prefixes so patch system can apply them (let's hope).

andy_g’s picture

thanks @moonray for what I'm sure is an excellent extension.

However, I can't make it available in my list of parsers. Here's what I have done so far:

- installed feeds 7.x 2.x dev, profile 2 etc
- patched from #58
- checked that the file FeedsProfile2Processor.inc is in the /plugins directory
- cleared the cache and restarted the webserver
- created a new Feeds Importer

..but when I get to choose the parser, I don't have the new option for Profile2..any ideas what I've missed?

TIA, Andy

andy_g’s picture

Doh as usual the act of posting revealed all.....it shows up as a processor not a parser!

moonray’s picture

Ah, yes, sorry. My bad. I meant processor, not parser.

andy_g’s picture

Works a treat! Thanks moonray, your work really helped me.

Hitby’s picture

Hi,
Thanks for the importer. This is just what I'm looking for.

I have exported the user data from a set of D7 profile fields and then run them through the importer to get them into a profile2 profile. The importer runs and claims it has updated the correct amount of records (only 49) but the profile fields are still empty.

Any help would be appreciated.

Cheers!

michielkenis’s picture

Same here. I get a confirmation message, but no user profiles are created (nor updated)...

mikolaskova’s picture

Version: 7.x-2.x-dev » 7.x-2.0-alpha8

same happens to me. No errors. Users imported but profile fields not filled...

moonray’s picture

You have to do the import in 2 steps.

1) import users using "User processor"
2) import profile fields using "User Profile processor"

You need to make sure your GUID (used as unique) is the same on both imports.

mikolaskova’s picture

thank you very much... but can I do this? Is there an additional module? (in the processor settings I can see only node, taxonomy and user)
I found a module, but it is for Drupal 6 only (https://drupal.org/project/content_profile_feeds)

mikolaskova’s picture

...now I see that it's about Profile 2. I'm still using the core 'Profile' Modul.
But feeds behaves same way. Users are imported, no profile fields.
I tried to import the users twice with unique username (and update option)...but profile fields were not filled.

Is there a way to import these profile fields?

kyleoliveira’s picture

In case anyone is interested in importing Profile2 profiles, but doesn't want to patch Feeds themselves, I've started a sandbox project that basically implements the patch from #58 in a way similar to Field Collection Feeds. You can get at it here: https://drupal.org/sandbox/kyleoliveira/2038851 . I just submitted it to the full project request queue, so any additional feedback would be appreciated. I'm kind of tired of waiting for this sort of thing to move forward with regard to contributed modules' entities and Feeds.

Whiskey’s picture

Thanks Kyleoliveira!

There seems to be a typo in your module; I had to rename the class and file of the class to Profile2_FeedsProfileProcessor (with underscore) to make it work. Excellent though!

kyleoliveira’s picture

Whiskey,

Good catch! I've fixed that in the commit I just pushed.

Thanks!

nasia123’s picture

It would be also nice to add a mapping for a Profile2 Privacy field

nasia123’s picture

Issue summary: View changes

i correct a typo

ibit’s picture

Chipie’s picture

Thanks moonray. Your patch works great.

twistor’s picture

Title: How to import Profile2-fields with new Users » Feeds integration.
Project: Feeds » Profile2
Version: 7.x-2.0-alpha8 »
Priority: Major » Normal
Issue summary: View changes

The patch looks pretty good, but this should happen in the Profile2 module, also, it can take advantage of the new entityprocessor as well!

joelstein’s picture

FYI, there's now a module called Feeds Profile2 which extends the built-in User processor so that Profile2 profiles can be created and updated as part of a user importer. Maybe it can serve as a stop-gap solution until proper support is added in Profile2?

rcodina’s picture

Module Feeds Profile2 worked for me!!! Thanks @joelstein!

kenorb’s picture

Project: Profile2 » Profile 2
Version: » 7.x-1.x-dev
hkovacs’s picture

patch @58 works for me.

module feeds profile did not work for me.

rcodina’s picture

@hkovacs There are patches available that improves Feeds Profile2 integration with Field Collection, etc

delacosta456’s picture

hi Guys

I had just notice today that when name field is attached directly to user account all component are available in feeds .. but when name field is attached to a profile only the Name field itself is available.

shall we report this to feeds guys or profiles2 guys

delacosta456’s picture

hi
Patch # 58 worked for me to on Panopoly distribution.

But i would like to suggest (if possible) option to select one or more bundle ... and let selected bundle's field available for mapping.

rickj’s picture

Status: Needs review » Closed (won't fix)

This functionality is provided by the Feeds Profile2 module. It creates a fully integrated solution, despite being a separate module.

damienmckenna’s picture

StatusFileSize
new5.79 KB
new626 bytes

For anyone who needs it, this is #58 (which is a patch for Feeds, not Profile2) with a fix for a API compatibility problem with the latest Feeds codebase.