Skip to content

Instantly share code, notes, and snippets.

@ranqiangjun
Last active August 8, 2017 10:11
Show Gist options
  • Save ranqiangjun/8d90c93c2498a5e78fb0e3f1028c44dc to your computer and use it in GitHub Desktop.
Save ranqiangjun/8d90c93c2498a5e78fb0e3f1028c44dc to your computer and use it in GitHub Desktop.
Computed_field:8.x-2.0-alpha4.

Code snippet tested.

$storage = \Drupal::entityManager()->getStorage("node");
$query = \Drupal::entityQuery('node');
$query->condition("type", $bundle);
$result = $query->execute();
foreach ($result as $nid) {
  $node = $storage->load($nid);
  $node->changed = REQUEST_TIME;
  $node->save();
}

how to batch update a computed field value for existed nodes? It works manually click save button on UI, but not work using code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment