Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tegansnyder/4323172 to your computer and use it in GitHub Desktop.
Save tegansnyder/4323172 to your computer and use it in GitHub Desktop.
Get a list of coupons used on recurring profiles in Magento
<?php
require_once 'app/Mage.php';
Varien_Profiler::enable();
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('default');
$profile = Mage::getModel('sales/recurring_profile')->getCollection();
$couponCodes = array();
foreach ($profile as $p) {
$data = unserialize($p->getOrderInfo());
if (isset($data['coupon_code'])) {
if (strlen($data['coupon_code']) > 1) {
$couponCodes[] = $data['coupon_code'];
}
}
}
echo '<pre>';
print_r(array_count_values($couponCodes));
echo '</pre>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment