Drupal 8 Entity API cheat sheet

PHOTO EMBED

Thu Oct 29 2020 20:21:43 GMT+0000 (Coordinated Universal Time)

Saved by @richard

$query = \Drupal::entityQuery('node')
  ->condition('type', 'article'),
  ->condition('field_foo', 42);
$nids = $query->execute();
$nodes = $node_storage->loadMultiple($nids);
 
foreach ($nodes as $n) {
  echo $n->title->value;            // "Lorem Ipsum..."
 
  // do whatever you would do with a node object (set fields, save, etc.)
  $n->set('title', "this is a test");
  $n->save();
}
content_copyCOPY

https://www.metaltoad.com/blog/drupal-8-entity-api-cheat-sheet