Hi I have used commerce coupon module. I have lot of entries of used coupon. So, right now I want to delete all commerce coupon from database. I have 860000 coupon entries in database. How can I delete all entries using custom module functionality?


Since coupons are entities, you'll want to delete them using the entity functions. As an example, if I want to delete all disabled coupons, something like this should work:

$disabled_coupons = commerce_coupon_load_multiple(array(), array('status' => 0));
$disabled_coupon_ids = array_keys($disabled_coupons);

If you need to batch them, you may want to try doing them in batches of 250-1000... not sure how many can be deleted successfully per batch. Then just let it run.

|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.