Skip to main content
removed "Drupal" and tags from the title
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

Programmatically create a term in Drupal 8?

Tweeted twitter.com/#!/StackDrupal/status/451495604196487168
added 488 characters in body
Source Link
Samsquanch
  • 483
  • 1
  • 4
  • 19

I'm attempting to add a lot of terms (~200) to a vocabulary, but I can't find any import modules that are updated for Drupal 8, and it seems the functions for doing this in Drupal 7 don't exist in Drupal 8. So, can anyone point me in the right direction for doing this?

I attempted to do it with entity_create, as suggested in the comments, with this code:

$term_create = entity_create('taxonomy_term', array('name' => 'test', 'vocabulary_name' => 'client'));

but I got this error:

Drupal\Core\Entity\EntityStorageException: Missing bundle for entity type taxonomy_term in Drupal\Core\Entity\FieldableEntityStorageControllerBase->create() (line 65 of core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php).

Any ideas?

I'm attempting to add a lot of terms (~200) to a vocabulary, but I can't find any import modules that are updated for Drupal 8, and it seems the functions for doing this in Drupal 7 don't exist in Drupal 8. So, can anyone point me in the right direction for doing this?

I'm attempting to add a lot of terms (~200) to a vocabulary, but I can't find any import modules that are updated for Drupal 8, and it seems the functions for doing this in Drupal 7 don't exist in Drupal 8. So, can anyone point me in the right direction for doing this?

I attempted to do it with entity_create, as suggested in the comments, with this code:

$term_create = entity_create('taxonomy_term', array('name' => 'test', 'vocabulary_name' => 'client'));

but I got this error:

Drupal\Core\Entity\EntityStorageException: Missing bundle for entity type taxonomy_term in Drupal\Core\Entity\FieldableEntityStorageControllerBase->create() (line 65 of core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php).

Any ideas?

Source Link
Samsquanch
  • 483
  • 1
  • 4
  • 19

Programmatically create term in Drupal 8?

I'm attempting to add a lot of terms (~200) to a vocabulary, but I can't find any import modules that are updated for Drupal 8, and it seems the functions for doing this in Drupal 7 don't exist in Drupal 8. So, can anyone point me in the right direction for doing this?