Created
October 16, 2015 20:57
-
-
Save andyg5000/c09d6fc713a4b44a3d9b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$entity_types = array( | |
'commerce_order' => array( | |
'entity_type' => 'commerce_order', | |
'id_field' => 'order_id', | |
), | |
'commerce_line_item' => array( | |
'entity_type' => 'commerce_line_item', | |
'id_field' => 'line_item_id', | |
), | |
'commerce_customer_profile' => array( | |
'entity_type' => 'commerce_customer_profile', | |
'id_field' => 'profile_id', | |
), | |
'commerce_payment_transaction' => array( | |
'entity_type' => 'commerce_payment_transaction', | |
'id_field' => 'transaction_id', | |
), | |
'commerce_product' => array( | |
'entity_type' => 'commerce_product', | |
'id_field' => 'product_id', | |
), | |
'node' => array( | |
'entity_type' => 'node', | |
'id_field' => 'nid', | |
'bundle' => array( | |
'name' => 'type', | |
'value' => 'product', | |
), | |
), | |
); | |
foreach($entity_types as $entity_type) { | |
$efq = new EntityFieldQuery(); | |
$efq->entityCondition('entity_type', $entity_type['entity_type']); | |
// Append budle information to the EFQ if provided. | |
if (!empty($entity_type['bundle'])) { | |
$efq->propertyCondition($entity_type['bundle']['name'], $entity_type['bundle']['value']); | |
}; | |
$results = $efq->execute(); | |
foreach ($results[$entity_type['entity_type']] as $result) { | |
entity_delete($entity_type['entity_type'], $result->{$entity_type['id_field']}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment