Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
My thought here is that there are situations where I would like to merge two fields that are coming over as arrays. Particularly in the case of dealing with entity reference fields, or other fields that have multiple values. An example migration may be like the following:
source:
plugin: d7_node
process:
temp_body:
plugin: iterator
source: field_section
process:
target_id:
plugin: migration
migration: field_collection_field_section_to_paragraph
source: value
temp_images:
plugin: iterator
source: field_image
process
target_id:
plugin: migration
migration: image_entities_to_paragraph
source: fid
paragraphs_field:
plugin: merge
source:
- @temp_body
- @temp_images
destination:
plugin: 'entity:node'
In this case I'm able to merge entities created from 2 different migrations into one entity reference field (specifically paragraphs). You might even be able to do this with 2 different types of paragraphs created using the EntityGenerate Process Plugin.
Comment | File | Size | Author |
---|---|---|---|
#5 | interdiff-2747939-3-5.txt | 718 bytes | generalredneck |
#5 | migrate_plus-merge_process_plugin-2747939-5.patch | 2.1 KB | generalredneck |
Comments
Comment #2
generalredneckLets try this on for size
Comment #3
generalredneckWe actually need merge not Union like my first attempt was
Comment #4
FluxSauce CreditAttribution: FluxSauce at Four Kitchens commentedSeems to function, but includes two var_dumps.
Comment #5
generalredneckFAILURE!
Ok, so here's the debug free version.
Comment #7
mikeryanCommitted, thanks!
Comment #9
Jaesin CreditAttribution: Jaesin at Chapter Three commentedThe Merge plugin throws MigrateException when source data isn't as nice as it could be.
In general, migrate handles source input pretty well as far as dealing with a single value vs an array.
Could be replaced with: