I have this json.
{
"ProductKey": "145.1",
"Product": {
"Title": "Product title",
"StartDate": null,
"EndDate": null,
"ProductKeywords": [{
"Name": "keyword 1"
},
{
"Name": "keyword 2"
},
{
"Name": "keyword 3"
}],
},
}
So in this case I can't create a separate migration file for the taxonomy terms because the ProductKeywords is an array and have multiple taxonomy terms.
So I have done it in a single migration file with entity_generate plugin for the taxonomy term entity reference field.
keywords:
- plugin: sub_process
source: keyword
process:
value: Name
- plugin: entity_generate
value_key: name
bundle_key: vid
bundle: keyword
entity_type: taxonomy_term
ignore_case: true
But the taxonomy terms created with entity_generate do not gets deleted with rollback.
I know there is a postRollback migration event, where we can execute some code after rollback. But I don't know how I can know which taxonomy terms needs to be deleted on the rollback.
Is there any example or hint available?
migration_lookup
instead ofentity_generate
for your taxonomies.