Created
December 17, 2012 22:52
-
-
Save tegansnyder/4323172 to your computer and use it in GitHub Desktop.
Get a list of coupons used on recurring profiles in Magento
This file contains 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 | |
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