0

I’m able to migrate users datas from a csv file with migrate, migrate_tools, migrate_source_csv and drush

Now, i’m trying to import datas from the same csv file to the Profile module (which provides configurable user profiles).

Here is my configuration file for user import. Obviously, i I add the profile fields in it (here field_profile_last_name, it doesn’t work).

id: user_migrate
migration_tags: null
migration_group: null
label: 'User migration from CSV'
source:
  plugin: csv
  path: /path-to-csv/users.csv
  header_row_count: 1
  keys:
    - weblogin
process:
  # user fields with custom fields : works !
  name: weblogin
  mail: email
  roles: roles
  field_last_name: nom_salarie
  field_first_name: prenom_salarie
  field_password_web_services: weblogin
  status: status
  field_profile_address: adresse1
  field_code: code
  field_date_de_naissance: date_naissance
  field_numero_societe: numsoc
  field_profile_function: qualification
  # profile fields : doesn't work
  field_profile_last_name: nom_salarie
destination:
  plugin: 'entity:user'
migration_dependencies:
  required: {  }
  optional: {  }

How can i migrate datas to the profile module ? What is the entity for this module.

0

I post an answer to my question. Feel free to comment or edit my answer in order to improve.

I’ve migrated users datas from a csv file. If you need help to do this, you can follow instructions in this questions : Import users into Drupal with data from a CSV file

Now, i import the profile data in a migration process that maintains the relationships between source and destination identifiers in map table.

So the profile is related to the correct uid.

More information on this here (Process plugin: migration_lookup):

https://www.drupal.org/docs/8/api/migrate-api/migrate-process-plugins/process-plugin-migration_lookup-formerly-migration

The configuration file looks like this. You have to adapt some values as :

uid: source: xxx

This takes the value of the xxx property in the source data, and looks it up in the map table associated with the users migration, returning the resulting user ID and assigning it to the destination uid property.

You have to adapt the fields of course and the key to your needs.

id: profile_migrate
migration_tags: null
migration_group: null
label: 'Profile migration from CSV'
source:
  plugin: csv
  path: /path/to/csv/users.csv
  header_row_count: 1
  keys:
    - weblogin
destination:
  plugin: entity:profile
process:
   type:
    plugin: default_value
    default_value: 'profile'
   uid:
     plugin: migration_lookup
     no_stub: true
     # previous user migration
     migration: user_migrate
     # property in the source data
     source: weblogin
   field_profile_last_name:
     plugin: get
     source: nom_salarie
   field_profile_first_name: prenom_salarie
   field_profile_address: adresse1
   field_date_de_naissance: date_naissance
   field_code: code
   field_numero_societe: numsoc
   field_profile_function: qualification
migration_dependencies:
  required: {  }
  optional: {  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.