Hoppa till huvudinnehåll

Updating taxonomy term name in Drupal 8

Here you can read how to use hook update for updating taxonomy terms in Drupal 8.

The hook update is added in the .install file like mymodule_update_800x

function mymodule_update_8001(&$sandbox) {
  $query = \Drupal::entityQuery('taxonomy_term');
  $query->condition('vid', 'county');
  $result = $query->execute();

  foreach($result as $term_id) {
    $term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($term_id);
    $term_name = $term->getName();
    // Transforming taxonomy term value. Doing my stuff.
    $value = $term_name . " län";
    $term->save(); // Important!!!!

Vi hjälper dig nå resultat. Kontakta oss Ring direkt på 08-20 90 04.

Stockholms Stadsmission väljer Drupal

Vi har fått förtroendet att hjälpa till med övergripande koncept, design och kontinuerlig utveckling av Stockholms Stadsmiss…

Cache in Drupal 8: How it worked, and what we wanted to be solved in D8

If you just want your content to be cached before Drupal 8, there were almost no problems, just turn on caching for anonymou…

Cache in Drupal 8: Introduction

In a series of blog posts we will go through how caching works in Drupal 8, to try to demystify the caching layer in Drupal …