I am upgrading site from Drupal 6 to Drupal 7 using migrate module. As profile is deprecated in Drupal 7 so I added fields to the user entity. I didn't had any problem migrating all the users but I have been looking around about how can I migrate user profiles and so far didnt find anything. On http://drupal.org/node/835738 - profile migration support was added for Drupal 6 but it wont work in my case as I am adding fields to the user and not using hidden profile module in D7.

Comments

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

You need to query the profile data from Drupal 6 and add field mappings from that to your Drupal 7 fields. The Drupal 6 profile schema is a bit complicated, but you can do it. Assume that in Drupal 6 you've created two profile fields First Name (which in the profile_fields table has a fid of 1) and Last Name (fid of 2):

...
    $this->addFieldMapping('field_first_name', 'profile_first_name');
    $this->addFieldMapping('field_last_name', 'profile_last_name');
...
  public function prepareRow($row) {
    $profile_fields = Database::getConnection('default', 'legacy')
      ->select('profile_values', 'pv')
      ->fields('pv', array('fid', 'value')
      ->condition('uid', $row->uid)
      ->execute()
      ->fetchAllKeyed();
    $this->profile_first_name = $profile_fields[1];
    $this->profile_last_name = $profile_fields[2];
  }

Does this help?

kgoel’s picture

Mike - Thanks for quick reply. I am using Profile 2 and Migrate Extras module to migrate user profiles however I am not sure what I am doing wrong as when I run drush mi than no error is thrown but I am getting Processed 0 (0 created, 0 updated, 0 failed, 0 ignored) in 0 sec . I know this is issue queue for migrate and not for migrate extras but thought you might be able to point me in the right direction.

mikeryan’s picture

Project: Migrate » Migrate Extras
Component: Code » Profile2

There's not much I can tell you without seeing how you're querying the source data, and mapping it to the profile2 fields.

mikeryan’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)
peteruithoven’s picture

I just discovered profiles are almost automatically migrated when you use the Drupal-to-Drupal data migration module.
http://drupal.org/project/migrate_d2d

You just need to add some field mappings, I needed for example:

    $this->addFieldMapping('field_first_name', 		'field_firstname');
    $this->addFieldMapping('field_last_name', 		'field_lastname');
    $this->addFieldMapping('field_phone', 			'field_phone');
    $this->addFieldMapping('field_usergroup', 		'field_usergroup');
    $this->addFieldMapping('field_usergroup_alternative', 'field_usergroup_anders');
    $this->addFieldMapping('field_minimus', 		'field_deminimus');
    $this->addFieldMapping('field_age_group', 		'field_agegroup');
    $this->addFieldMapping('field_liability', 		'field_liability'); //TODO needed?
    $this->addFieldMapping('field_company_name', 	'field_companyname');

You can get all these names from the migrate interface where you can see what's mapped and what's not.
(Great stuff Mike!)

visualfox’s picture

Hello Mike,

In the prepareRow function you should modify the $row variable not the $this (which is the migrate object itself), based on your example:

$this->profile_first_name = $profile_fields[1];
$this->profile_last_name = $profile_fields[2];

need to be

$row->profile_first_name = $profile_fields[1];
$row->profile_last_name = $profile_fields[2];