We have a vocabulary of nested (hierarchical) category terms on a site and are using the Migrate API (via CSV) to import product entities that each have a category term.
The problem is that some of the nested term names are repeated so the importer would not know which nested term to use. For example:
PARENT 1--Child 1 PARENT 1--Child 2 PARENT 2--Child 1 PARENT 2--Child 2
As you can see, the term "Child 1" is used twice, but with different parents.
I can see two possible solutions but I don't know how to go about achieving them. So any help would be appreciated.
1) Would it be possible to include the hierarchy in a delimited field on the CSV and let Migrate create and nest all of the terms and then map the product entity term referring to the last term automatically.
For example. "Parent 1, Child, 1, Child 2"
2) Or, using a source plugin and TWO fields on the CSV, where one is the product category term and the other field is the parent and somehow have Migrate know which parent term ID to use for the category?
Currently, the category YML looks like this:
field_prod_category:
-
plugin: explode
source: WebCategory1
delimiter: ','
-
plugin: entity_generate
source:
value_key: name
bundle: product_categories
entity_type: taxonomy_term
ignore_case: true