Skip to content

Instantly share code, notes, and snippets.

@crittermike
Created June 7, 2020 03:22
Show Gist options
  • Save crittermike/7233a55079cd112d51d44ce0d1939ec6 to your computer and use it in GitHub Desktop.
Save crittermike/7233a55079cd112d51d44ce0d1939ec6 to your computer and use it in GitHub Desktop.
Rebuild taxonomy_index table for all nodes
<?php
$query = \Drupal::entityQuery('node');
$ids = $query->accessCheck(FALSE)->execute();
$storage_handler = \Drupal::entityTypeManager()->getStorage('node');
// If you have a lot of nodes, you may have to split this up via
// array_chunk() instead of trying to load all nodes at one time.
$entities = $storage_handler->loadMultiple($ids);
foreach ($entities as $entity) { 
taxonomy_build_node_index($entity); 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment