Add suport for fields with subcomponets when one of them is a migration e.g. image field and the field is multiple
Closed this issue · 6 comments
When a field is multiple and with subcomponents you can use a JSON like this
"[{\"value\":\"body11\"},{\"value\":\"body12\"}]"
When a field has subcomponents and requires a migration BUT is not multiple you can use a CSV like this
title,field_imageTarget_id,field_imageAlt
article1,"magic.png","alt text"
When a field is multiple and requires a migration you can use a CSV like this (Alt field will be empty)
title,field_images
article1,"[\"magic.png\",\"demo.jpg\"]"
But there is no way to migrate a field that requires a migration and is multiple
I achieved this by using the iterator
process plugin in an override. I can provide a PR to hook this up properly in migrate_default_content_add_target_migration()
but the question is how you want the format to be in the actual migrations. I am using the following structure (with YAML, not JSON):
-
<field-name>:
-
<target-migration-source-id-field>: <target-migration-source-id>
-
<target-migration-source-id-field>: <target-migration-source-id>
-
<target-migration-source-id-field>: <target-migration-source-id>
I.e.
-
field_paragraphs:
-
uuid: 685f5fdc-fedd-4e7d-ad0d-920fb469b990
-
uuid: 0448ad95-f8bf-4426-947c-052a796b5bf7
-
uuid: 28204eaa-8e98-4be3-8db7-157103ef60e1
For images, I guess it would be:
-
field_images:
-
filename: foo.png
alt: 'Some picture'
-
filename: bar.png
alt: 'Some other picture'
See #31
I don't know why we haven't thought about using the iterator.
Leaves the source data file pretty clean and readable so is great.
I'll wait before merging to do a bit more testing.
Any update on this?
Would be great to have this in place.
The reality is that we are still using the 1.0 version of the module but we didn't had the need to use the features that are in HEAD.
This is surely the last feature before 1.1 or 2.0 that should happen during the next months
The structure for doing this is the following:
-
title: 'Example page'
field_paragraphs: 77152a7c-e331-43ea-a927-6fd687831368
field_another_paragraphs:
-
uuid: 77152a7c-e331-43ea-a927-6fd687831368
-
uuid: 77152a7c-e331-43ea-a927-6fd687831369
field_image:
-
filename: test.jpg
alt: mytest
-
filename: ymbralogo.png
alt: ymbra