0

I'm trying to migrate two user fields in Drupal 7 (name in two languajes) to a translated field in Drupal 8. I have tried several options but all failed. I have two yml templates (one for the user and another for the translation with parameter translations:true) but not working. The user is migrated correctly. The translation of the user is created correctly. The field of the user is correctly but the translated field is not translated.

These are a part of the yml files...

migrate_D7_user.yml

source:
  plugin: d7_user
process:
  uid:
    -
      plugin: get
      source: uid
  name:
    -
      plugin: get
      source: name_english
  langcode:
    -
      plugin: default_value
      default_value: en
destination:
  plugin: 'entity:user'

migrate_D7_user_translation.yml

source:
  plugin: d7_user
  translations: true
process:
  uid:
    -
      plugin: migration
      source: uid
      migration: migrate_d7_user
  name:
    -
      plugin: get
      source: name_spanish
  langcode:
    -
      plugin: default_value
      default_value: es

destination:
  plugin: 'entity:user'
  translations: true

Thank you in advance, Juanjo.

1
  • Now it works. When you do the migration of all users not works fine. But if you migrate only one o several users works fine. Finally I discovered that the problem is in the migration of the user admin (user/1).
    – Juanjo
    Commented Feb 12, 2020 at 8:32

1 Answer 1

0

Now it works. There was a problem with the migration of the user admin (user/1). If you migrate admin user, then you can't edit translations of any user. Now I put a custom source plugin with function query() overwritten:

/**
   * {@inheritdoc}
   */
  public function query() {

    $query = parent::query();

   // Only migrate users not admin (1)
    $query->condition('uid', '1', '<>');
    return $query;
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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