Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6668197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:00:52+00:00 2026-05-26T03:00:52+00:00

I have searched on the net and on this site for a solution but

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:00:52+00:00Added an answer on May 26, 2026 at 3:00 am

    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

    /*@var $coupon Mage_SalesRule_Model_Coupon */
    $coupon = Mage::getModel('salesrule/coupon');
    $coupon->load('dd_38WX9N', 'code');
    
    if($coupon->getId()){
        /* @var $resourceCouponUsage Mage_SalesRule_Model_Mysql4_Coupon_Usage */
        $resourceCouponUsage = Mage::getResourceModel('salesrule/coupon_usage');
        $read = $resourceCouponUsage->getReadConnection();
        $select = $read->select()
                    ->from($resourceCouponUsage->getMainTable())
                    ->where('coupon_id = ?', $coupon->getId());
    
        $data = $read->fetchAll($select);
        print_r($data);
        foreach($data as $couponUsage){
            $customer = Mage::getModel('customer/customer')->load($couponUsage['customer_id']);
            echo $customer->getName();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched this question but didn't get / or understood the answer I
I have searched lot about AdventureWorks2008R2 database, but couldn't get proper URL. Can anybody
I have searched the site for information and found this: ASP.NET C# Active Directory
I have searched the net and searched the net only to not quite find
I am using c# .net. Thanks in advance for any help. I have searched
I have tried dllimport and extern command without any success. Searched the net for
I have searched everywhere and can't find anything about this: I have a checkbox
I'm new to asp.net mvc, but I've thoroughly searched on this topic everywhere. I've
I have searched through the net and still have no clue how to do
I have tried everything, searched the net for two hours or even more and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.