Skip to content

Instantly share code, notes, and snippets.

@opi
Created June 11, 2021 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save opi/53832a7b8d8229e645f38e2e049e97de to your computer and use it in GitHub Desktop.
Save opi/53832a7b8d8229e645f38e2e049e97de to your computer and use it in GitHub Desktop.
Drupal 9 : Migrate D7 body field to paragraph
  1. Run body_to_paragraph migration
  2. Run my_node_migration migration
id: body_to_paragraph
class: null
migration_tags:
- 'Drupal 7'
- Content
migration_group: paragraphs
label: 'Paragraphs: Blog body to text'
source:
plugin: d7_node_complete
node_type: blog # Your bundle
process:
field_p_text: body
# body is the D7 field
# field_p_text is the D9 paragraph text field
destination:
plugin: 'entity_reference_revisions:paragraph'
default_bundle: text # My D9 paragraph bundle
migration_dependencies:
required: { }
optional: { }
id: my_node_migration
class: Drupal\node\Plugin\migrate\D7NodeTranslation
migration_tags:
- 'Drupal 7'
- Content
migration_group: nodes
label: 'Node complete (blog)'
source:
plugin: d7_node_complete
node_type: blog # My D7/D9 bundle
process:
nid:
-
plugin: get
source: tnid
# [...] All your regular fields
# body: body # Do not migrate body anymore
field_paragraphs/target_id:
-
plugin: migration_lookup
migration:
- body_to_paragraph
no_stub: true
source: tnid
-
plugin: extract
index:
- '0'
field_paragraphs/target_revision_id:
-
plugin: migration_lookup
migration:
- body_to_paragraph
source: tnid
no_stub: true
-
plugin: extract
index:
- 1
field_metatag:
-
plugin: d7_metatag_entities
source: pseudo_metatag_entities
destination:
plugin: 'entity_complete:node'
translations: true
default_bundle: blog
migration_dependencies:
required:
- body_to_paragraph
optional: { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment