I have searched on the net and on this site for a solution but couldn’t find any.
I would like to get the customer name associated to a coupon code in Magento. I found some code for the times the coupon code was used but I couldn’t get the customer name.
I tried the following code:
<?php
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
umask(0);
Mage::app( 'admin' );
$coupon = Mage::getModel('salesrule/coupon/usage');
$coupon->load('dd_38WX9N', 'code');
if($coupon->getId()) {
$timesUsed = $coupon->getTimesUsed();
$customer = $coupon->getCustomerId();
echo $timesUsed;
echo $customer;
}
?>
Could someone please help me with that and point me to the right direction.
Thanks a lot for your help.
Daniel
Here is the good solution. you need to use the resource and not the model to get access to the table salesrule_coupon_usage and get the customer_id list