Drupal 8: delete all nodes of the same type

后端 未结 9 1955
予麋鹿
予麋鹿 2021-02-19 01:34

I have a need to remove all nodes of the same type in Drupal 8 (there are over 7k of nodes).

It wouldn\'t be a problem for Drupal 7 (DB query + node_del

9条回答
  •  佛祖请我去吃肉
    2021-02-19 02:22

    For Drupal 9.0 works fine

      $ids = \Drupal::entityQuery('node')
        ->condition('type', 'article')
        ->execute();
    
      $storage_handler = \Drupal::entityTypeManager()->getStorage("node");
      $entities = $storage_handler->loadMultiple($ids);
      $storage_handler->delete($entities);
    

提交回复
热议问题