You are here

function get_term_id in Content Import 8.9

To get Termid available.

2 calls to get_term_id()
create_term in ./contentimport.module
To Create Terms if it is not available.
get_term_reference in ./contentimport.module
To get Reference field ids.

File

./contentimport.module, line 98
Module file for Contentimport.

Code

function get_term_id($term, $vid) {
  $query = \Drupal::database()
    ->select('taxonomy_term_field_data', 't');
  $query
    ->fields('t', [
    'tid',
  ]);
  $query
    ->condition('t.vid', $vid);
  $query
    ->condition('t.name', $term);
  $termRes = $query
    ->execute()
    ->fetchAll();
  foreach ($termRes as $val) {
    $term_id = $val->tid;
  }
  return $term_id;
}