Hi. I have a list in excel of places with adress, telephone and state an capital. Already found how to import basic information each column to one field via .csv files. But there is a problem. How to create and link the state and capital vocabulary. The structure is like this:

- State
--Capital

But in excel the capital and state are in different column.

So how can I create the terms with this Hierarchie and add to the new node in migration?

Comments

koffer’s picture

Title: How tocreate nodes from excel with Hierarchie terms » How create nodes from excel with Hierarchie terms
koffer’s picture

Title: How create nodes from excel with Hierarchie terms » How create nodes from excel with hierarchy terms
mikeryan’s picture

Title: How create nodes from excel with hierarchy terms » How to create nodes with hierarchical terms
Status: Active » Postponed (maintainer needs more info)

So, when you're creating the terms as a side-effect of mapping them directly in a node migration (as opposed to migrating them in a separate term migration and referencing that migration), there's no direct way to set the parent - i.e., you need to do some manual work. One way would be to map the capital directly, which will create it without a parent, then in your migration's complete() function pull the term from the node object, see if it has a parent, and if not create the parent (state) term and set the parent on the term object.

Another option is to make a separate term migration that reads the same Excel file - it can create the terms and their hierarchy directly through straight-forward mappings, then your node migration can reference that migration.

mikeryan’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)
koffer’s picture

Thanks for your answer mikeryan. Right know We are writing a node to explain how we solve the problem:

How to create nodes with hierarchical terms from excel
https://www.drupal.org/node/2448189