Auto-create terms during node migration

by donquixote   Last Updated July 27, 2018 15:07 PM

I have a CSV file that I want to import as nodes with Migrate API.

Some of the columns contain names (separated by semicolon) that should become term names, referenced from the node via term reference fields.

Ideally I want to create the terms on the fly, when the node is imported. It should check whether a term with the name already exists, and if not, create it.

Ideally, I would not even have to create a separate migration class for each term. If that is not possible, at least I want these term migrations to be as simple as possible. They would need an "empty source", so I don't have to provide a CSV file for each vocabulary.


I think I vaguely remember that such functionality exists, but cannot find documentation about it.

See also https://www.drupal.org/project/migrate_d2d/issues/1957364:

Migrate module's handling of term_reference fields has a nice shorthand that lets you create terms on the fly as they come in as strings.

This saves you having to create a dependent migration to do the taxonomy terms first, and then match them up in the node migration.

However, this does not work with D2D, as the field value coming in from the foreign Drupal DB is just term tids. Hence, terms get created but their names are the old tid values.

So apparently it does exist, I just don't find the documentation. (this stackexchange question will change that!)



Related Questions



How to edit vocabulary machine name?

Updated November 29, 2017 21:07 PM

migrate taxonomy term csv

Updated May 14, 2018 17:07 PM