I'm using json api feeds from another D8 site to migrate the data into new D8 site.
I setup an importer for taxonomy terms that is working fine. i.e. mycustom_migrator
I setup an importer for a custom entity that has an entity reference field to taxonomy terms (unlimited)
data example:
json api feeds...
"field_source_d8_terms": {
"data": [
{
"type": "taxonomy_term--mycustomtype",
"id": "189086b4-c59c-44bb-ad63-7bd2b9fceabc"
},
{
"type": "taxonomy_term--mycustomtype",
"id": "ce3486f4-19cb-4a76-a897-3dfc9440baf5"
}
],
source...
name: source_d8_terms
label: 'D8 Terms'
selector: /relationships/field_source_d8_terms
I don't know how to write the process plugin to iterate through the terms from the json feeds and import into the custom entity reference field. Please help.
field_mycustomentityfield:
plugin: migration_lookup
source: 'source_d8_terms/data/id'
migration: mycustom_migrator
Comments
Comment #2
yohkyHello uceap-web,
Did you find a solution ... a year ago ?
I have exactly the same problem when trying to import D8 terms to another D8 via json.
Best
Comment #3
dpeamit commentedI had a slightly different use case as I was not migration from D8 to D8. I dint use the migration_lookup or entity_lookup (although you can use that as well). Here is what worked for me
#meetings is the entity ref field
field_meeting:
plugin: attach_meetings
source: Meetings
The source is a json , with multiple meetings objects (similar to yours). You can then iterate through through the array and attach that to the original entity (you can also check if it already attached to avoid attaching it multiple times)
Comment #4
danflanagan8I know this is way old, but this looks like something the sub_process plugin should be able to handle. When you have an array of arrays, you can use sub_process. It looks like
source_d8_terms/datawould be an array of arrays (where each array has an 'id' and a 'type'), so I think you could just do this: