Iterate over Magento coupons to remove old coupons.
<?php
# Bootstrap
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path());
require 'app/Mage.php';
$app = Mage::app('', 'store');
$couponsCollection = Mage::getModel('salesrule/coupon')->getCollection();
Mage::getSingleton('core/resource_iterator')->walk(
$couponsCollection->getSelect(),
array('callback')
);
function callback($args) {
$times_used = intval($args['row']['times_used']);
$usage_per_customer = intval($args['row']['usage_per_customer']);
$usage_limit = $args['row']['usage_limit'];
echo $args['row']['code'] . "\n";
if (
$usage_limit == '1' &&
$times_used > 0 &&
($times_used >= $usage_per_customer)
) {
// Mage::getModel('salesrule/coupon')
// ->load($args['row']['coupon_id'])
// ->delete();
}
}