Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to delete multiple nodes by ID in Drupal 8 using hook update
* Delete multiple nodes by ID.
function YOU_MODULE_NAME_update_8001() {
$nids = [8418,8419];
/** @var \Drupal\node\NodeStorageInterface $storage */
$node_storage = \Drupal::entityTypeManager()->getStorage('node');
if ($nodes = $storage->loadMultiple($nids)) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment