I am trying to add new functionality and need to show coupon code in the Orders grid. I was able to show the column in the grid but it is not showing the data. I followed this link https://meetanshi.com/blog/add-coupon-code-column-in-magento-2-order-grid/ And at the end it requires running a MySQL command manually, if I do the same it does starts showing codes but without the query, it is not showing any data. I want to show the coupon code in the admin grid immediately after the order is added. Should I try to write an observer for success order and then run the query or any other option is available.

1 Answer 1


Add in or add an InstallSchema.php from this path of your custom module:



Then after, you have to map the coupon_code column to sales_order column in your di.xml configuration:

<virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid" type="Magento\Sales\Model\ResourceModel\Grid">
        <argument name="columns" xsi:type="array">
            <item name="coupon_code" xsi:type="string">sales_order.coupon_code</item>

Then in your sales_order_grid.xml

<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <columns name="sales_order_columns">
        <column name="coupon_code">
            <argument name="data" xsi:type="array">
            <item name="js_config" xsi:type="array">
                <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item>
            <item name="config" xsi:type="array">
                <item name="visible" xsi:type="boolean">true</item>
                <item name="dataType" xsi:type="string">text</item>
                <item name="align" xsi:type="string">left</item>
                <item name="label" xsi:type="string" translate="true">Coupon Code</item>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.