The Product categories vocabulary after importing six products whose category column held paths such as Animals > Dogs > Food: Animals holds Cats and Dogs, each with its own Accessories and Food, and Plants holds Soil and Trees.
The settings of the Import Taxonomy Terms Hierarchy tamper: Input delimiter set to >, Vocabulary set to Product categories, Allow terms to be auto created checked, Match the first term anywhere in the hierarchy unchecked.

Feeds Tamper Term Hierarchy turns a category written as a path, such as Animals > Dogs > Food, into taxonomy terms during a Feeds import. It creates the levels that do not exist yet, each under the one before it, and the term reference field of the imported item gets the term at the end of the path. For catalogs, directories and any source that holds its categories as a path.

Features

  • 🌳 A hierarchy from a path. Each level of the path that does not exist yet is created under the level before it, in the vocabulary you choose.
  • 🏷️ Names matched within their parent. Animals > Dogs > Food and Animals > Cats > Food give two Food terms, one under each parent. Importing the same feed again finds the terms of the first run instead of duplicating them, and a new level under an existing branch creates only that level.
  • ⚙️ Existing vocabularies. With Allow terms to be auto created off, a value whose terms do not exist is skipped instead of created. With Match the first term anywhere in the hierarchy on, a partial path such as Dogs > Food attaches to the Dogs already under Animals.
  • 🔤 Untidy sources. Spaces around each level are trimmed, and empty levels, as in Animals > > Food or a trailing delimiter, are skipped instead of saved as terms without a name.
  • ⚡ Repeated categories looked up once. The plugin remembers the terms it has resolved, so rows that repeat a category do not query the database again: 300 rows repeating three paths made 7 term queries, one per distinct level.

 Animals holds Cats and Dogs, each with its own Accessories and Food, and Plants holds Soil and Trees.

Quick start

composer require drupal/feeds_tamper_term_hierarchy
drush en feeds_tamper_term_hierarchy
  1. On your feed type's Mapping tab, map the column that holds the path to the term reference field, open its settings and set Reference by to Term ID.
  2. On the Tamper tab, add Import Taxonomy Terms Hierarchy to that column.
  3. Set the Input delimiter and the Vocabulary, and save.
  4. Import the feed. The vocabulary now holds every path as a hierarchy, and each item references the term at the end of its path.

 Input delimiter set to >, Vocabulary set to Product categories, Allow terms to be auto created checked, Match the first term anywhere in the hierarchy unchecked.

 Term ID.

The category column mapped to the Category field by term ID.

Good to know

  • The plugin hands the mapping a term ID, so the target has to reference terms by Term ID. On the default, Term name, Feeds finds no term named after that number: the vocabulary gets the hierarchy, but the items are saved with the field empty, and with Autocreate entities on they are not imported at all.
  • One value holds one path. When a column holds several, add Tamper's Explode plugin before this one, splitting on the separator between paths.
  • Names are matched as Drupal compares them, without regard to case: dogs finds an existing Dogs.
  • With Match the first term anywhere in the hierarchy on, when several terms share the first name of the path, the first match wins.

Additional requirements

  • Drupal 10.2 or later, or Drupal 11.
  • Tamper 1.0 or later.
  • The Taxonomy module from Drupal core.
  • Feeds Tamper and Feeds, to use it in a Feeds import.

Community documentation

  • README: the settings, the mapping by term ID, and several paths in one column.

Supporting this module

Developed and maintained by Bloomidea. Bloomidea offers support and custom development for this module.

Supporting organizations: 
Development and maintenance

Project information

Releases