Monday, March 6, 2023

How to migrate Embedded Data in drupal 9

 Step 1: We need to install the Migrate Plus module and enable it.



Step 2: Created the vocabulary and the name of the vocabulary "Migration demo showcase"

  • Click on the list term
  • Added the term
Step 3: Create the custom module custom/migration_feature

1. migration_features.info.yml 

name: Migration features
description: Demo of migration features
core: 8.x
core_version_requirement: ^8 || ^9
packages: Demo Migrations Features
type: module
dependencies:
  - migrate_plus:migrate_plus
  - drupal:migrate

2. migrate_term_simple_way.yml

migrate_term_simple_way.yml

id: migrate_term_simple_way
label: To migrate terms in simple way
source:
  plugin: embedded_data
  data_rows:
    - name: voc1
      desc: voc1 desc
      parent: NULL
    - name: voc2
      desc: voc2 desc
      parent: NULL
    - name: voc3
      desc: voc3 desc
      parent: 1
  ids:
    name:
      type: string
process:
  name: name
  description: desc
  parent: parent  
  vid:
    plugin: default_value
    default_value: migration_demo_showcase
destination:
  plugin: 'entity:taxonomy_term'

Step:4 Now enable the custom module and follow the CMD steps

1. composer require drush/drush


2. drush cr


3. drush migrate:import migrate_term_simple_way





Step 5: Output of Parent id wise migration


Step 6: Rollback the taxonomy term so you can rollback commands like

1. drush migrate:rollback migrate_term_simple_way



Step7: Output of Parent Name-wise migration

1. migration_lookup.yml
id: migrate_term
label: migrating terms
source:
  plugin: embedded_data
  data_rows:
    - name: voc1
      desc: voc1 desc
      parent: NULL
    - name: voc2
      desc: voc2 desc
      parent: NULL
    - name: voc3
      desc: voc3 desc
      parent: voc1
  ids:
    name:
      type: string
process:
  name: name
  description: desc
  parent:
    plugin: migration_lookup
    migration: migrate_term
    source: parent
  vid:
    plugin: default_value
    default_value: migration_demo_showcase
destination:
  plugin: 'entity:taxonomy_term'

2. Run the command 

drush migrate:import migrate_term



Output


Step 8: For example both migration files compare.



No comments:

Post a Comment

If you have any problem please let me know.