You are here

function taxonomy_csv_import_term in Taxonomy CSV import/export 5

Get or create a term with the given name in the given vocabulary and given parent.

1 call to taxonomy_csv_import_term()
taxonomy_csv_import_line in ./taxonomy_csv.module

File

./taxonomy_csv.module, line 277
Quick import of lists of terms from a csv file.

Code

function taxonomy_csv_import_term($term, $update = TRUE) {
  if ($update && ($existing_term = taxonomy_csv_find_term($term['name'], $term['vid'], isset($term['parent']) ? $term['parent'] : NULL))) {
    foreach (array(
      'description',
      'synonyms',
    ) as $key) {
      if (array_key_exists($key, $term)) {
        $existing_term[$key] = $term[$key];
      }
    }
    $term = $existing_term;
  }
  taxonomy_save_term($term);
  return $term;
}