Skip to content

Instantly share code, notes, and snippets.

@slivorezka
Created March 21, 2018 15:29
Show Gist options
  • Save slivorezka/7ed96aeb83d2fb68009641fcc867fbdd to your computer and use it in GitHub Desktop.
Save slivorezka/7ed96aeb83d2fb68009641fcc867fbdd to your computer and use it in GitHub Desktop.
Drupal 8: Reset weigh for all terms
<?php
$manager = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
$tree = $manager->loadTree('VOC_NAME', 0, 0, TRUE);
foreach ($tree as $term) {
$term->setWeight(0);
$term->save();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment