0

I migrate all the article of an old blog to drupal new website i have my image_migration :

id: image
label: "Migrate all media"
migration_group: image_migration
source:
  plugin: image
  constants:
    DRUPAL_FILE_DIRECTORY: "public://images"
process:
  psf_source_image_path:
    plugin: file_path
    source: image
  psf_destination_full_path:
    -
      plugin: concat
      delimiter: /
      source:
        - constants/DRUPAL_FILE_DIRECTORY
        - image
    -
      plugin: urlencode
  uri:
    plugin: file_copy
    source:
      - "@psf_source_image_path"
      - "@psf_destination_full_path"
destination:
  plugin: entity:file

migration_dependencies: {}

I have my user_migration :

id: user_migrate
label: 'Migrate le User principal'
source:
  plugin: embedded_data
  data_rows:
    - legacy_id: 101
      public_name: 'Neron'
      user_email: 'neron@test.com'
      user_timezone: 'Europe/Paris'
      user_password: 'Viva Las Vegan'
      user_status: 'active'
      member_since: 'August 17, 2020'
      user_roles: 'webmaster, administrator'
  ids:
    legacy_id:
      type: integer
process:
  mail: user_email
  init: user_email
  timezone: user_timezone
  name:
    - plugin: machine_name
      source: public_name
    - plugin: make_unique_entity_field
      entity_type: user
      field: name
      postfix: _
  pass:
    plugin: callback
    callable: md5
    source: user_password
  status:
    plugin: static_map
    source: user_status
    map:
      inactive: 0
      active: 1
    created:
      plugin: format_date
      source: member_since
      from_format: 'F j, Y'
      to_format: 'U'
    changed: '@created'
    access: '@created'
    login: '@created'
    roles:
      - plugin: skip_on_empty
        method: process
        source: user_roles
      - plugin: explode
        delimiter: ','
      - plugin: callback
        callable: trim
      - plugin: static_map
        map:
          'forum admin': administrator
          'webmaster': administrator
        default_value: null
destination:
  plugin: 'entity:user'
  md5_passwords: true
migration_dependencies: {}

and my article migration :

#Migration metadata
id: article
label: Migrate list of articles
migration_group: article_migration

#Source plugin, id defined in the @MigrateSource annotation
# in the src/Plugin/migrate/source/Article.php file.
source:
  plugin: article
  key: migrate

 # Process plugin
process:
  title: title
  field_image/target_id:
    -
      plugin: migration_lookup
      migration: image
      source: id
      no_stub: true
    -
      plugin: skip_on_empty
      method: row
      message: 'Image not found'

  field_image/alt: balise_alt
  body/value: content
  body/format:
    plugin: default_value
    default_value: restricted_html


# Destination plugin
destination:
  plugin: entity:node
  default_bundle: article



# Nothing needed here, it is a single table without any other relation.
migration_dependencies:
  required:
    - image
  optional: []

all migration works but i don't know How can look_up the user to be the author of all the article (i try different name for the author name machine in the article migration my plugin stop it working) if someone has a better methods

2
  • The key used for lookup must by the same key as used in the referenced migration. Since you used numeric legacy_id as primary key in migration user_migrate, the migration_lookup plugin now also wants numeric ID as source, not the machine name of the user. – Hudri Aug 19 '20 at 14:53
  • i adjust with this i use this in the process : process: uid: plugin: migration_lookup migration: user_migrate source: legacy_id no_stub: true but it's still don't consider uid on consideration – Matthias Screed Aug 19 '20 at 15:03

Your Answer

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

Browse other questions tagged or ask your own question.