Skip to content

Instantly share code, notes, and snippets.

@adamfranco
Created January 16, 2018 14:39
Show Gist options
  • Save adamfranco/4af29ce0dd3047df1532323019d6a291 to your computer and use it in GitHub Desktop.
Save adamfranco/4af29ce0dd3047df1532323019d6a291 to your computer and use it in GitHub Desktop.
Short script to bulk-update story nodes in Drupal. Execute with `drush8 php-script show_stories_in_newsroom.php`
<?php
$query = \Drupal::entityQuery('node');
$query->condition('type', 'story');
$nids = $query->execute();
echo "Updating " . count($nids) . " stories:\n";
$nodes = node_load_multiple($nids);
foreach ($nodes as $node) {
$node->field_aggregate = TRUE;
$node->save();
echo '.';
}
echo "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment