Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The coupon code used during checkout is stored on the primary order table (<code>sales_flat_order</code>) when the customer checks out. If there is no value, then no coupon code was used. However, the data for the grid in the admin comes from the <code>sales_flat_order_grid</code> table; it comes from there instead of the primary order table for performance reasons which become particularly evident on very high traffic sites.</p> <p>Now that we know where the data is that you need to filter on, and where the data for the grid comes from, we can move on to build it!</p> <p>The first thing that you will need to do is add a <code>coupon_code</code> column to the <code>sales_flat_order_grid</code> table matching the definition of the column on the <code>sales_flat_order</code> table. The values in the <code>coupon_code</code> column of <code>sales_flat_order</code> should automatically populate into <code>sales_flat_order_grid</code> once the matching column is there and your cache storage has been flushed.</p> <p>The data is updated on the order save, so to be specific, new orders and orders updated via the admin (even a comment on the order) will have the data populated. For existing orders, run a data upgrade script to copy the values over.</p> <p>After the data/schemas are in place, you'll want to have the grid show a filterable column for it. For this you will want to rewrite the <code>Mage_Adminhtml_Block_Sales_Order_Grid</code> class from your custom module (please don't edit the core files directly, it will haunt you later) and override the <code>_prepareColumns</code> method with one that includes your column definition:</p> <pre><code> $this-&gt;addColumn('coupon_code', array( 'header' =&gt; Mage::helper('sales')-&gt;__('Coupon Code'), 'index' =&gt; 'coupon_code', )); </code></pre> <p>If you're very fresh on Magento development, I'd venture to say that I've only begun to help you. But you'll have plenty of reference points from which to dig in and build the functionality you need. HTH! :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload