I have a JSON file with an entry that looks like this:

"taxonomy": "abc/historical_controls/abc2000_2013"

In my YML file I have it mapped like this:

      plugin: skip_on_empty
      method: process
      source: taxonomy
      plugin: explode
      delimiter: /
      plugin: callback
      callable: ltrim
      plugin: callback
      callable: rtrim
      plugin: entity_generate
      value_key: name
      entity_type: taxonomy_term
      bundle_key: vid
      bundle: abc_asset_taxonomy_auto

This works in that it brings over the terms correctly, but in a flat file. I need them to come over so that each term is a child of the term before it so:

abc historical_controls abc2000_2013

The problem is there is an unknown number of items. It could be 2, it could be 10.

Is there a way to migrate hierarchical taxonomy with an unknown number of parent child relationships?

Note, I've seen several examples that use a determinant number of sources but this wouldn't work here. The "Migrate Hierarchical Taxonomy" module uses a determinant number as well. How can I achieve this with the Migrate API preferably without writing a custom plugin?


1 Answer 1


Maybe too late but for the sake of being complete: I think you'll find the answer here Using Drupal 8's Migrate API, how can I map a nested (hierarchical) taxonomy term to the imported entity? First migrate the terms without parents. After that update the parent-field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.