2

I have a 5000+ entries for custom Entities created by the RedHen module (https://drupal.org/project/redhen). I want to wipe them completely from the system (they are all test entries). How can I do this quickly? I tried to get Views Bulk Operations and the Delete All modules but neither seem to be picking up the custom entities.

1

You can delete multiple entities using below API functions

entity_load

Load entities from the database.

The entities are stored in a static memory cache, and will not require database access if loaded again during the same page request.

$entity_type: The entity type to load, e.g. node or user.

$ids: An array of entity IDs, or FALSE to load all entities.

entity_delete_multiple

Permanently delete multiple entities.

For Example to delete all node entities

<?php
  $results = entity_load('node');
  $entity_ids = array_keys($results);
  entity_delete_multiple('node', $entity_ids);
  ?>
| improve this answer | |
  • Yes this looks right, but I'm confused on proper usages of this. Ideally i just want to run this once or twice. Would I add this to my custom module and have it hook and run with update.php? – jhoffmcd Mar 8 '14 at 0:12
  • How many Entity Types do you have ? – Anil Sagar Mar 8 '14 at 2:30
  • Actually I was able to put this in a preprocess function on a specific page I created and it worked! I had to separate it out in chunks though, I had over 100,000 entities in the DB. So it worked! Thank You. – jhoffmcd Mar 9 '14 at 4:30
1

This simple module might help you: https://www.drupal.org/project/entity_bulk_delete

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.