Problem/Motivation

Hi and thank you very much for this module!

I recently created #3624952: Add hierarchy to the CSV export and allow import of exported CSV in Taxonomy Manager and wondered if Enhanced Taxonomy Manager is eventually able to solve this?
Seems only the import of taxonomy term fields is missing here? (Without following references).

Does this module allow creating taxonomy terms from import without providing tid, language and other technical properties?

I think there are two typical use-cases:
- Creating taxonomy terms freshly from a different project, so TID etc. need to be newly created
- Copying taxonomy terms from a copy of the project (e.g. dev, staging, ...)

Thanks!!

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

anybody created an issue. See original summary.

deadnorth’s picture

Thanks! To your questions:

  • Yes, Import already creates terms without term IDs, language or other technical properties. It takes one term per line, nested with leading dashes, with an optional description after a pipe, such as -- Laptops | Portable computers. Names, hierarchy and descriptions can be moved to another project today.
  • No, it doesn't import field values yet, and it can't read back what the CSV export writes.

I'm working on that now. The CSV export will include the vocabulary's own fields, and Import gets a CSV tab that reads that file back. Every row creates a new term, parents are matched by their path of names, and entity references are left out, as you suggested. That covers both of your use cases without term IDs. I'll post here when it is committed.

  • b60e7f91 committed on 2.2.x
    Issue #3624953: Import terms with their field values from CSV
    
    The CSV...

  • b03b697a committed on 2.2.x
    Issue #3624953: Leave fields the user may not view out of the CSV export...
deadnorth’s picture

Status: Active » Fixed

This is in 2.2.3: composer require 'drupal/etm:^2.2.3', then clear caches.

Export: on the tree page, Export > CSV Download now lists the vocabulary's own fields next to Name, Description, Status, Weight and Parent Path. Tick the ones you want; they are written under their machine names.

Import: Import now has a CSV tab. Choose the exported file, or paste CSV, and press Import Terms. For example:

Name,Parent Path,field_code,field_tags
Hardware,,H1,tools|metal
Hand Tools,Hardware,H1-01,tools
Hammers,Hardware > Hand Tools,H1-01-01,
  • Every row creates a new term, so no term IDs, language or other technical properties are needed. Term ID and Depth columns from an export are read past.
  • Parents are found by their path of names, among the rows above first and then among the existing terms, so an export rebuilds its own hierarchy in another vocabulary or on another site.
  • Text, number, boolean, list, email, telephone, link, URI and date fields are carried. Entity references are left out, as you suggested, since their IDs differ between sites. Separate the values of a multi-value field with |.
  • Columns are matched by machine name or label; any column the import doesn't recognise is named in the result rather than silently dropped. A failing row is reported by its row number and the rest still import.
  • Fields the exporting user may not view are left out of the export, and fields the importing user may not edit are left out of the import.

Both of your cases work: creating terms fresh in another project, and copying terms from a dev or staging copy into another site.

Known limits, which the next release will address: up to 5,000 rows per import; a term with several parents is exported once per parent; a > inside a term name breaks parent paths.

Thanks for the suggestion. If anything in your data doesn't come through, please reopen this with a few rows of the CSV.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.