Adding order attribute to the orders grid in Magento 1.4.1

POSTED ON Jul 27, 2010 IN in How To

Custom Column in Orders Grid

I think everyone has noticed that since 1.4.1 Magento uses separate table for displaying of the order grid in the backend.

I have created a small example with trivial client request, that displays the main aspects of such a customization.

Your client asked you to add customer phone number to the orders grid. It requires a column adding to sales_flat_order_grid table and filling it with telephone value from sales_flat_order_address table. You need to create a custom module to implement the feature. The module should consist of setup script that uses sales setup model, observer that observes grid population and adds the custom column to it, and, of course, the layout file that adds the column to the grid.

The module name will be EcomDev_PhoneForOrderGrid and it will be placed in local code pool, so you need to create the directory app/code/local/EcomDev/PhoneForOrderGrid.

Then you need to create the setup script to define custom column in the grid table:
app/code/local/EcomDev/PhoneForOrderGrid/sql/ecomdev_phoneforordergrid_setup/mysql4-install-0.1.0.php

<?php
/**
 * Setup scripts, add new column and fulfills
 * its values to existing rows
 *
 */
/* @var $this Mage_Sales_Model_Mysql4_Setup */
$this->startSetup();
// Add column to grid table
$this->getConnection()->addColumn(
    $this->getTable('sales/order_grid'),
    'customer_telephone',
    "varchar(255) not null default ''"
);
// Add key to table for this field,
// it will improve the speed of searching & sorting by the field
$this->getConnection()->addKey(
    $this->getTable('sales/order_grid'),
    'customer_telephone',
    'customer_telephone'
);
// Now you need to fullfill existing rows with data from address table
$select = $this->getConnection()->select();
$select->join(
    array('address'=>$this->getTable('sales/order_address')),
    $this->getConnection()->quoteInto(
        'address.parent_id = order_grid.entity_id AND address.address_type = ?',
        Mage_Sales_Model_Quote_Address::TYPE_BILLING
    ),
    array('customer_telephone' => 'telephone')
);
$this->getConnection()->query(
    $select->crossUpdateFromSelect(
        array('order_grid' => $this->getTable('sales/order_grid'))
    )
);
$this->endSetup();

The next step is the creation of the observer that handles grid columns generation event and adds your custom column. The event name is “sales_order_resource_init_virtual_grid_columns”.
app/code/local/EcomDev/PhoneForOrderGrid/Model/Observer.php

<?php
/**
 * Event observer model
 *
 *
 */
class EcomDev_PhoneForOrderGrid_Model_Observer
{
    /**
     * Adds virtual grid column to order grid records generation
     *
     * @param Varien_Event_Observer $observer
     * @return void
     */
    public function addColumnToResource(Varien_Event_Observer $observer)
    {
        /* @var $resource Mage_Sales_Model_Mysql4_Order */
        $resource = $observer->getEvent()->getResource();
        $resource->addVirtualGridColumn(
            'customer_telephone',
            'sales/order_address',
            array('billing_address_id' => 'entity_id'),
            'telephone'
        );
    }
}

Now you need to display you column in orders grid widget, so you need to create the layout update:
app/design/adminhtml/default/default/layout/ecomdev/phoneforordergrid.xml

<?xml version="1.0"?>
<layout>
    <!-- main layout definition that adds the column -->
    <add_order_grid_column_handle>
        <reference name="sales_order.grid">
            <action method="addColumnAfter">
                <columnId>customer_telephone</columnId>
                <arguments module="customer" translate="header">
                    <header>Telephone</header>
                    <index>customer_telephone</index>
                    <type>text</type>
                </arguments>
                <after>shipping_name</after>
            </action>
        </reference>
    </add_order_grid_column_handle>
    <!-- order grid action -->
    <adminhtml_sales_order_grid>
        <!-- apply the layout handle defined above -->
        <update handle="add_order_grid_column_handle" />
    </adminhtml_sales_order_grid>
    <!-- order grid view action -->
    <adminhtml_sales_order_index>
        <!-- apply the layout handle defined above -->
        <update handle="add_order_grid_column_handle" />
    </adminhtml_sales_order_index>
</layout>

After you have created the logic of the customization you need to configure the module and enable it by the adding configuration and bootstrap files:
app/code/local/EcomDev/PhoneForOrderGrid/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <EcomDev_PhoneForOrderGrid>
            <version>0.1.0</version> <!-- define version for sql upgrade -->
        </EcomDev_PhoneForOrderGrid>
    </modules>
    <global>
        <models>
            <ecomdev_phoneforordergrid>
                <class>EcomDev_PhoneForOrderGrid_Model</class>
            </ecomdev_phoneforordergrid>
        </models>
        <events>
            <!-- Add observer configuration -->
            <sales_order_resource_init_virtual_grid_columns>
                <observers>
                    <ecomdev_phoneforordergrid>
                        <model>ecomdev_phoneforordergrid/observer</model>
                        <method>addColumnToResource</method>
                    </ecomdev_phoneforordergrid>
                </observers>
            </sales_order_resource_init_virtual_grid_columns>
        </events>
        <resources>
            <!-- initialize sql upgrade setup -->
            <ecomdev_phoneforordergrid_setup>
                <setup>
                    <module>EcomDev_PhoneForOrderGrid</module>
                    <class>Mage_Sales_Model_Mysql4_Setup</class>
                </setup>
            </ecomdev_phoneforordergrid_setup>
        </resources>
    </global>
    <adminhtml>
        <layout>
             <!-- layout upgrade configuration -->
            <updates>
                <ecomdev_phoneforordergrid>
                    <file>ecomdev/phoneforordergrid.xml</file>
                </ecomdev_phoneforordergrid>
            </updates>
        </layout>
    </adminhtml>
</config>

app/etc/modules/EcomDev_PhoneForOrderGrid.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
 Module bootstrap file
-->
<config>
    <modules>
        <EcomDev_PhoneForOrderGrid>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Sales />
            </depends>
        </EcomDev_PhoneForOrderGrid>
    </modules>
</config>

Now your client is satisfied!

And even more:

If you need to add an existing column from sales_flat_order table (subtotal for example), then it is much more easier, because resource model detects the same name of columns in grid and main table and fulfill it automatically, so you shouldn’t create the observer to add it. Just add a new column, fulfill old values and create a layout action for the column adding to grid.

Ivan Chepurnyi
Magento guru / System architect
Ivan started as Magento Core developer in early 2007, since that time he already has 6 years of experience in different areas of Magento development. During all that time he developed enormous amount of modules and customizations, so now almost every dark corner in Magento functionality is investigated by him. He can’t keep that knowledge in secret, that why he's sharing it with the community and helps finding the way out of Magento complexity maze.

115 Responses to “Adding order attribute to the orders grid in Magento 1.4.1”

  1. Hi, thanks for this great tutorial. Works 100%. Can you explain how you would include the shipping from the order into the grid rather than the telephone number. I can sort of see how it is done but could do with a bit of guidance of the query to use in the mysql4 file.

    Thanks, Alistair

    • Hi Alistair,
      If you want to add more fields from shipping address, you need to add just more columns to grid table, like (shipping_country, shipping_city, shipping_postcode, etc) and map the corresponding fields from shipping address entry (country_id, city, postcode). To fulfill existing rows just add these columns to the select object in the install script. Send an email to ivan dot chepurnyi at ecomdev dot org if you have any questions.

      • Hi friend,

        As per your instruction, i coded. Its working fine. Thanks..

        Also I need to know how to add custom options like size, color attributes in magento admin sales order grid..

        Thanks in advance..

        • Hi,
          I need to add a field called barcode to sales order, that is viewed only from the admin in the shipment processing page. Can I guide me how to add this field & display in Admin Form

          Thanks
          Dexter

  2. I see it will display telephones in order grid after module install.
    What about telephones from new orders?

    • That’s why EcomDev_PhoneForOrderGrid_Model_Observer observes sales_order_resource_init_virtual_grid_columns event. It adds telephone to virtual grid columns definitions, so order resource model will update the new values during the grid table updating.

  3. Hi,

    Do I need to do something similar if I want to add a custom field to the checkout form?
    I was able to add a new tab with some fields but don’t know how to save them with the order.
    I was following several modules and tutorials but I think changes in 1.4.1 break it.

    Thanks

    • Hi Pablo,

      To add a custom attribute to checkout form, you need:

      1. Add it to quote and order entities.
      2. Add your input field to the checkout form through the layout
      3. Than you need to create event observer for one of the events for saving the data to quote, it can be controller (postdispatch) or model (possible evens can be found in checkout models)
      4. Add your attribute code to sales_convert_quote fieldset with to_order aspect.

      Than you can perform some steps from this tutorial to display your custom field in the orders grid.

  4. Hi Ivan,

    I think that adding the field to the quote and order entities is not enough because in 1.4.1
    we need to add a column to sales_flat_order and sales_flat_quote.
    http://www.widgetsandburritos.com/technical/programming/customer-order-comment-magento-1-4-1-0/

    This post looks interesting:
    http://www.magentocommerce.com/boards/viewthread/19344/

    I’m not sure what event to use and how to actually save the custom field to the quote.
    Once it is saved to the quote I think that step 4 you mentioned should move it to the order automatically.

    Thanks

    • Hi Pablo,

      Actually if you have extended your setup model from Mage_Sales_Model_Mysql4_Setup you even should not think about adding a column. Sales Setup Model performs it depends on wich type of attribute you have specified.

      This code will add a new column to sales_flat_order table, but it wont add a record to eav_attribute table, because sales module is flat now.
      $installer->addAttribute(‘order’, ‘custom_attribute_name’, array(‘type’=>’int’));

      Where $installer is an instance of Mage_Sales_Model_Mysql4_Setup or another class that was extended from it.

      So if your extension was using Sales Setup Model, so it will work in 1.4.1 without any modifications. But a lot of extensions that are placed on Magento Connect written without thinking about upgrade-ability (eg. using another setup model, instead of customized module’s one) and when new Magento version releases store owners always have headache.

      The event names you are looking for:
      - controller_action_predispatch_checkout_onepage_saveorder
      Use Mage::getSingleton(‘checkout/type_onepage’)->getQuote() to save data and
      $observer->getEvent()->getControllerAction()->getRequest() to get the request

      - controller_action_predispatch_checkout_multishipping_overviewpost
      Use Mage::getSingleton(‘checkout/type_multishipping’)->getQuote() to save data and $observer->getEvent()->getControllerAction()->getRequest() to get the request

  5. I’ve created a setup script at code/local/Mycomp/mymod/sql/Mymod_setup/mysql4-install-0.1.0.php:
    startSetup();
    $installer->addAttribute(‘order’, ‘myfield1′, array(‘type’=>’text’));
    $installer->endSetup();

    I’ve deleted mymod_setup from core_resource and cleared the cache.
    When magento creates a new entry in core_resource I don’t see my new column in sales_flat_order.

    In your example, why do you use $this->getConnection()->addColumn instead of $installer->addAttribute?

    How do I use the quote to save data?
    Shouldn’t I get the quote from the event?
    Mage::getSingleton(‘checkout/type_onepage’)->getQuote()

    Thanks

    • Seems you have forgotten to define your custom setup model and extend it from Mage_Sales_Model_Mysql4_Setup. You can do it in such a way:
      config.xml

      <global>
          <resources>
              <mymod_setup>
                      <setup>
                           <module>Mycomp_Mymod</module>
                           <class>Mycomp_Mymod_Model_Mysql4_Setup</class>
                      <setup>
              </mymod_setup>
          </resources>
      </global>
      

      Mycomp/Mymod/Model/Mysql4/Setup.php

      <?php
      class Mycomp_Mymod_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
      {
      }
      

      Also please make the letter case in the directory names the same with definitions in your module configuration file.
      Mycomp/Mymod/sql/Mymod_setup/ is invalid directory name if you have defined in resources ‘mymod_setup’.

      As for the quote data saving.
      You need to call something like the following on event:

      $quote = Mage::getSingleton(‘checkout/type_onepage’)-&gt;getQuote();
      $quote-&gt;setMyfield1('value');
      

      where setMyfield1 method is camel style transformed setter name of your custom attribute ‘myfield1′.

      As for the event data. This is not possible, because in those events there are no quote object passed, because all of them are called before a controller action dispatch. But the object you need is used as a singleton in a checkout model.

  6. Hi. I want show the payment method, but in observer i don’t know how to write the contitional for the join

            $resource = $observer->getEvent()->getResource();
            $resource->addVirtualGridColumn(
                'customer_paymentmethod',
                'sales/order_payment',
                array('entity_id' =&gt; 'entity_id'),
                'method'
            );
    

    Some body can hep me?

    • Hi Pedro,

      Payment method for order is linked through field parent_id. So the condition should be like the following:
      array(‘entity_id’ => ‘parent_id’) // These will be rendered in query like ‘order_payment.parent_id = order.entity_id’

      Sincerely

      • Thanks, but not work i’m using megento 1.4.1.1 after the update froma 1.3.2.4 version

        my script to setup is:

        $this->startSetup();
        $this->getConnection()->addColumn(
            $this->getTable('sales/order_grid'),
            'customer_paymentmethod',
            "varchar(255) not null default ''"
        );
        $this->getConnection()->addKey(
            $this->getTable('sales/order_grid'),
            'customer_paymentmethod',
            'customer_paymentmethod'
        );
        $select = $this->getConnection()->select();
        $select->join(
            array('address'=>$this->getTable('sales/order_payment')),
               'address.parent_id = order_grid.entity_id ',
            array('customer_paymentmethod' => 'method')
        );
        $this->getConnection()->query(
            $select->crossUpdateFromSelect(
                array('order_grid' => $this->getTable('sales/order_grid'))
            )
        );
        $this->endSetup();
        

        Thanks

        • What an error are you receiving? And have you reinstalled your custom module after the changes I have asked about?
          To reinstall the module you need to remove record from core_resource table with your module resource name and flush Magento cache.

  7. Ivan,

    Instead of extending Mage_Sales_Model_Mysql4_Setup, can I just instantiate it in my mysql4-install.x.php file?

    I need to be able to modify the sales table, profile table and to create my own custom flat table from the same install script.

    Thanks

  8. Thank you. It’s been helpful.
    There’s a little typo in config.xml as the version should be 0.1.0 and not 1.0.0.
    I first copied-pasted quite stupidly and wondered why the setup didn’t work :)

    • Actually it should work with 1.0.0 version because it setup script will look for versions from 0.0.0 to 1.0.0 version for a setup. Maybe you have forgotten to clear cache first time? But anyway thanks for finding typo, it is corrected now :)

  9. Hi,
    tks for your script, this can help me !

    But, if i want to display products names and SKU, do you think it’s easy ? Or i must change more code ?

    Best regards,

    Cedric

    • Ivan Chepurnyi says:

      Product Names and SKU’s it is separate table with multiple rows, so you maybe you should think about creation of column in grid table. Would be much easier to observe order collection after load event and load collection of items for current page and assign these items to according orders. Then just add custom renderer for order grid that will display these items there.

  10. Hi Ivan,

    I’ve to add one custom field as “Representative Number” in admin order creation form. I am able to add this field in the form and it appears while creating the order. To save this field in database, I’ve done the following changes ..

    1)- Added one attribute in eav_attribute table with “entity_type_id” = 15, attribute_code as “representative_number”, “backend_type” = varchar etc.
    2)- After adding attribute I’ve added new column in “sales_flat_order” table as “representative_number”.
    3)- To save this field value, I made change in core/Mage/Adminhtml/Model/Sales/Order/Create.php in function importPostData($data) and added following lines

    if (isset($data['representative_number']))
    {
         $this->getQuote()->addData($data['representative_number']);
    }
    

    After doing so when I save order, representative number field is not saved in database, any idea what I’m missing?

    Any kind of help will be greatly appreciated.

    Thanks in advance,
    Anil

    • Ivan Chepurnyi says:

      If you have done it by yourself not through the sql upgrade, there might be a problem in DDL cache. Magento caches table structures even if cache is enabled. So only one way to make it appear during the save you need to push “Flush Magento Cache” button on “Cache Management” page.

  11. Thanks for the nice write-up. In case anyone else finds it useful, I used the following to add the payment method to the grid:

    // Add payment column to grid table
    $this->getConnection()->addColumn(
        $this->getTable('sales/order_grid'),
        'payment',
        "varchar(255) not null default ''"
    );
    // Add key to table for this field,
    $this->getConnection()->addKey(
        $this->getTable('sales/order_grid'),
        'payment',
        'payment'
    );
    // Now fill existing rows with data from address table
    $select = $this->getConnection()->select();
    $select->join(
        array('order_payment'=>$this->getTable('sales/order_payment')),
        $this->getConnection()->quoteInto('order_payment.parent_id = order_grid.entity_id'),
        array('payment' => 'method')
    );
    $this->getConnection()->query(
        $select->crossUpdateFromSelect(
            array('order_grid' => $this->getTable('sales/order_grid'))
        )
    );
    
  12. Hi Ivan,

    I want to show Payment Method, User Group & company in Order Grid on order list page. & I am succeed in it but the problem I am facing is its not allowing me to sort/search using these additional Columns. Can you please help.

    Thanks,
    Amit

    • Ivan Chepurnyi says:

      Have you added these columns to grid table? What is the error, that you get while trying to search/sort column?

      • Amit Mishra says:

        Hi Ivan,

        I have followed the process you mentioned above for adding a new column in Order Grid. I wanted to add Payment Method, Customer Group & Company fields in the Order Grid.
        In mysql setup file I modified your code like –

        $this->startSetup();
        // Add column to grid table
        $this->getConnection()->addColumn(
            $this->getTable('sales/order_grid'),
            'customer_group_id',
            "int(11) not null default '0'"
        );
        $this->getConnection()->addColumn(
            $this->getTable('sales/order_grid'),
            'method',
            "varchar(255) not null default ''"
        );
        $this->getConnection()->addColumn(
            $this->getTable('sales/order_grid'),
            'company',
            "varchar(255) not null default ''"
        );
        // Add key to table for this field,
        // it will improve the speed of searching &amp; sorting by the field
        $this->getConnection()->addKey(
            $this->getTable('sales/order_grid'),
            'customer_group_id',
            'customer_group_id'
        );
        $this->getConnection()->addKey(
            $this->getTable('sales/order_grid'),
            'method',
            'method'
        );
        $this->getConnection()->addKey(
            $this->getTable('sales/order_grid'),
            'company',
            'company'
        );
        // Now you need to fullfill existing rows with data from address table
        $select = $this->getConnection()->select();
        $select->join(
            array('address'=>$this->getTable('sales/order_address')),
            $this->getConnection()->quoteInto(
                'address.parent_id = order_grid.entity_id AND address.address_type = ?',
                Mage_Sales_Model_Quote_Address::TYPE_BILLING
            ),
            array('company' => 'company')
        );
        $select->join(
            array('order_payment'=>$this->getTable('sales/order_payment')),
            $this->getConnection()->quoteInto(
                'order_payment.parent_id = order_grid.entity_id'
            ),
            array('method' => 'method')
        );
        $select->join(
            array('order'=>$this->getTable('sales/order')),
            $this->getConnection()->quoteInto(
                'order.entity_id = order_grid.entity_id'
            ),
            array('customer_group_id' => 'customer_group_id')
        );
        $this->getConnection()->query(
            $select->crossUpdateFromSelect(
                array('order_grid' => $this->getTable('sales/order_grid'))
            )
        );
        $this->endSetup();
        &amp; in Observer.php I wrote -
        class SnvApp_FieldsForOrderGrid_Model_Observer
        {
            /**
             * Adds virtual grid column to order grid records generation
             *
             * @param Varien_Event_Observer $observer
             * @return void
             */
            public function addColumnToResource(Varien_Event_Observer $observer)
            {
                /* @var $resource Mage_Sales_Model_Mysql4_Order */
                $resource = $observer->getEvent()->getResource();
                $resource->addVirtualGridColumn(
                    'company',
                    'sales/order_address',
                    array('billing_address_id' => 'entity_id'),
                    'company'
                );
        		$resource->addVirtualGridColumn(
                    'method',
                    'sales/order_payment',
                    array('parent_id' => 'entity_id'),
                    'method'
                );
        		$resource->addVirtualGridColumn(
                    'customer_group_id',
                    'sales/order',
                    array('entity_id' => 'entity_id'),
                    'customer_group_id'
                );
            }
        }
        

        & did required changes in the files you mentioned above. but still no field been added to the order grid table neither I can access them. Please help me. I need it to finish as soon as possible.

        Thanks
        Amit

        • Amit Mishra says:

          Hi Ivan,

          Sorry to bother you. Its working fine. I just have to refresh cache of my magento store. Thanks a lot for such a nice tutorial.

          Regards,
          Amit

          • Amit Mishra says:

            Hi Ivan,

            I have added fields in Order Grid but after that Order are not being Placed on front end.
            Please help me.

            Regards,
            Amit

          • Amit Mishra says:

            Here is the error I am getting –
            exception ‘Zend_Db_Statement_Exception’ with message ‘SQLSTATE[42000]: Syntax error or access violation: 1110 Column ‘customer_group_id’ specified twice’ in /var/www/vhosts/maleedge.com/subdomains/dev/httpdocs/en/lib/Zend/Db/Statement/Pdo.php:234

  13. Hi, and thanks for the excellent guide!

    I want to add billing or shipping company to the grid, but i dont know what to replace in your code.

    Ive replaced all references from “customer_telephone” to “billing_company” but i dont get it to work.

    Any idea what im doing wrong?

    Thanks
    Johan

    • Ivan Chepurnyi says:

      Please send me your code to my email: ivan [dot] chepurnyi [at] ecomdev.org and I will help you.

    • Amit Mishra says:

      Hi John,

      Just use company instead of billing_company. it will work. If still confused then see the code I posted in the comment above to your comment.

      Regards,
      Amit

      • Thanks Amit for your suggestion!

        Ive tried using company instead of billing_company but no difference.

        Didnt you need to change the references from telephone to company in app/design/adminhtml/default/default/layout/ecomdev/phoneforordergrid.xml to get it working to?

        you can email directly if you want info [at] kabelbutiken [dot] com

        Thanks
        Johan

  14. Hi, and thank you for this tutorial. Works great! I’ve even gotten it to show my custom order fields in the grid, which is perfect! How would I go about adding my custom order fields to the admin sales order view? I’d like it in the main order info box, below Order Date, Order Status, and Purchased From.

    I see where that is happening in app/design/adminhtml/default/default/template/sales/order/view/info.phtml, and I know what to add, like I can use $_order->getCustomFieldName(), and modified this file to test out viewing my fields, but how can I do that without modifying this actual file?

    Thank you!

    • Ivan Chepurnyi says:

      Hi Sandie,

      The only way you can go is use layout file, for adminhtml_sales_order_view handle you need to set your template custom template for order_info block.

  15. Hi Ivan,

    Thanks a lot for this nice module and also for your helpful conversation.

    I used this module in a magento site, it is working nicely. But, after using this, I can’t submit order, It says “There was an error processing your order. Please contact us or try again later.”.

    Also, I can’t add order comments in order details at magento admin panel. Whenever I tried to add comments, it says “Could not add comments”.

    I tried a lot……but found nothing.. :( …except one….

    Whenever I changed the observer events in this file app/code/local/EcomDev/PhoneForOrderGrid/etc/config.xml, I can submit order and also can add comments. But, in that case, telephone number is not showing for new order in order grid. It is showing the telephone number for the older orders nicely.

    I changed the event name to “sales_resource_init_virtual_grid_columns” instead of using “sales_order_resource_init_virtual_grid_columns”.

    What can be the cause here? Please help me.

    Thanks again.

    Ronniee

    • Ivan Chepurnyi says:

      Please enable logging errors and look into var/log/exception.log file for details of the error.
      Please post these error text here

      • Hi… Please help me.. I am also same problem… i got error when my place order…“There was an error processing your order. Please contact us or try again later.”.

        Please Help me….

        My error log(exception.log) file error:

        2010-11-19T06:14:02+00:00 ERR (3):
        exception ‘Zend_Db_Statement_Exception’ with message ‘SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘main_table.parent_id’ in ‘on clause” in C:xampphtdocsnossalibZendDbStatementPdo.php:234
        Stack trace:
        #0 C:xampphtdocsnossalibZendDbStatement.php(300): Zend_Db_Statement_Pdo->_execute(Array)
        #1 C:xampphtdocsnossalibZendDbAdapterAbstract.php(468): Zend_Db_Statement->execute(Array)
        #2 C:xampphtdocsnossalibZendDbAdapterPdoAbstract.php(238): Zend_Db_Adapter_Abstract->query(‘INSERT INTO `sa…’, Array)
        #3 C:xampphtdocsnossalibVarienDbAdapterPdoMysql.php(333): Zend_Db_Adapter_Pdo_Abstract->query(‘INSERT INTO `sa…’, Array)
        #4 C:xampphtdocsnossaappcodecoreMageSalesModelMysql4OrderAbstract.php(174): Varien_Db_Adapter_Pdo_Mysql->query(‘INSERT INTO `sa…’)
        #5 C:xampphtdocsnossaappcodecoreMageSalesModelAbstract.php(51): Mage_Sales_Model_Mysql4_Order_Abstract->updateGridRecords(’3′)
        #6 C:xampphtdocsnossaappcodecoreMageSalesModelOrder.php(1744): Mage_Sales_Model_Abstract->_afterSave()
        #7 C:xampphtdocsnossaappcodecoreMageCoreModelAbstract.php(307): Mage_Sales_Model_Order->_afterSave()
        #8 C:xampphtdocsnossaappcodecoreMageCoreModelResourceTransaction.php(150): Mage_Core_Model_Abstract->save()
        #9 C:xampphtdocsnossaappcodecoreMageSalesModelServiceQuote.php(181): Mage_Core_Model_Resource_Transaction->save()
        #10 C:xampphtdocsnossaappcodecoreMageSalesModelServiceQuote.php(227): Mage_Sales_Model_Service_Quote->submitOrder()
        #11 C:xampphtdocsnossaappcodecoreMageCheckoutModelTypeOnepage.php(618): Mage_Sales_Model_Service_Quote->submitAll()
        #12 C:xampphtdocsnossaappcodecoreMageCheckoutcontrollersOnepageController.php(451): Mage_Checkout_Model_Type_Onepage->saveOrder()
        #13 C:xampphtdocsnossaappcodecoreMageCoreControllerVarienAction.php(418): Mage_Checkout_OnepageController->saveOrderAction()
        #14 C:xampphtdocsnossaappcodecoreMageCoreControllerVarienRouterStandard.php(254): Mage_Core_Controller_Varien_Action->dispatch(‘saveOrder’)
        #15 C:xampphtdocsnossaappcodecoreMageCoreControllerVarienFront.php(177): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
        #16 C:xampphtdocsnossaappcodecoreMageCoreModelApp.php(304): Mage_Core_Controller_Varien_Front->dispatch()
        #17 C:xampphtdocsnossaappMage.php(596): Mage_Core_Model_App->run(Array)
        #18 C:xampphtdocsnossaindex.php(80): Mage::run(”, ‘store’)
        #19 {main}
        2010-11-19T06:14:05+00:00 ERR (3):
        exception ‘Zend_Mail_Transport_Exception’ with message ‘Unable to send mail’ in C:xampphtdocsnossalibZendMailTransportSendmail.php:105
        Stack trace:
        #0 C:xampphtdocsnossalibZendMailTransportAbstract.php(348): Zend_Mail_Transport_Sendmail->_sendMail()
        #1 C:xampphtdocsnossalibZendMail.php(973): Zend_Mail_Transport_Abstract->send(Object(Zend_Mail))
        #2 C:xampphtdocsnossaappcodecoreMageCoreModelEmailTemplate.php(392): Zend_Mail->send()
        #3 C:xampphtdocsnossaappcodecoreMageCoreModelEmailTemplate.php(445): Mage_Core_Model_Email_Template->send(‘owner@example.c…’, ‘Owner’, Array)
        #4 C:xampphtdocsnossaappcodecoreMageCheckoutHelperData.php(217): Mage_Core_Model_Email_Template->sendTransactional(‘checkout_paymen…’, ‘general’, ‘owner@example.c…’, ‘Owner’, Array)
        #5 C:xampphtdocsnossaappcodecoreMageCheckoutcontrollersOnepageController.php(479): Mage_Checkout_Helper_Data->sendPaymentFailedEmail(Object(Mage_Sales_Model_Quote), ‘SQLSTATE[42S22]…’)
        #6 C:xampphtdocsnossaappcodecoreMageCoreControllerVarienAction.php(418): Mage_Checkout_OnepageController->saveOrderAction()
        #7 C:xampphtdocsnossaappcodecoreMageCoreControllerVarienRouterStandard.php(254): Mage_Core_Controller_Varien_Action->dispatch(‘saveOrder’)
        #8 C:xampphtdocsnossaappcodecoreMageCoreControllerVarienFront.php(177): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
        #9 C:xampphtdocsnossaappcodecoreMageCoreModelApp.php(304): Mage_Core_Controller_Varien_Front->dispatch()
        #10 C:xampphtdocsnossaappMage.php(596): Mage_Core_Model_App->run(Array)
        #11 C:xampphtdocsnossaindex.php(80): Mage::run(”, ‘store’)
        #12 {main}

        Thanks,

        C.vignesh

      • very nice module. everything working well but i have this problem. when place order in my site it through the exception “There was an error processing your order. Please contact us or try again later.”

    • Hi.. Ronniee.. did you got any solution for this error.. Replay me…

      Now i am in same fix like this….

      • Same problem here… reason for checkout error is located in the observer (think so). When removing “$resource->addVirtualGridColumn()”, order is submitted, but the new field(s) in grid table stay of couse empty.
        I’m not very familiar with the magento core api, so no idea what is going wrong :(
        I need this nice piece of code for an annoying client >.<

        Used Magento version is 1.4.1.1

        • Ivan Chepurnyi says:

          I found the problem in Vignesh’s code.. Seems all of you used the same part of code from Amit:

          $resource->addVirtualGridColumn(
              ‘method’,
              ‘sales/order_payment’,
              array(‘parent_id’ => ‘entity_id’),
              ‘method’
          );
          

          Here is the problem in third argument for addVirtualGridColumn method: array(‘parent_id’ => ‘entity_id’) where ‘parent_id’ and ‘entity_id’ should be swapped, because array key is the colum in order table and array value is the column in target table.
          So the final code should be:

          $resource->addVirtualGridColumn(
              'method',
              'sales/order_payment',
              array('entity_id' => 'parent_id'),
              'method'
          );
          
          • Ivan you are my HERO! :D

            [img]http://www.greensmilies.com/smile/smiley_emoticons_torte5.gif[/img]

            Yesterday i changed these two columns for testing, but also changed it for telephone… *plonk*

            Working code is:

            $resource->addVirtualGridColumn(
            	'customer_telephone',
            	'sales/order_address',
            	array('billing_address_id' => 'entity_id'),
            	'telephone'
            );
            $resource->addVirtualGridColumn(
            	'paymethod',
            	'sales/order_payment',
            	array('entity_id' => 'parent_id'),
            	'method'
            );
            
  16. Hello again,

    I cant find a way to display anything else then phonenumber (that dosnt work on all orders either)

    Is there anyone here that could put together a module package like the example above that add columns for billing company and payment method.

    Thanks
    Johan

  17. Hi Ivan,

    Adminhtml grids are setup to open a view page when a user clicks on one of the rows. How would you go about inserting a custom view summary block via Ajax into a list page when a row is clicked, instead of going to the new view page? For example if you are in Sales -> Orders and click on an order row, instead of getting a detailed view, a summary shows up on the top of the page and lists cart details, and billing/shipping information. Clicking ‘View’ would still take you to the regular view page.

    Thanks,
    Angelko

    • Ivan Chepurnyi says:

      Hi Angelko,

      It won’t be a problem, just create a custom cotroller with layout which is loaded without default handle and use standard order view blocks.

  18. Got the OrderController for Sales -> Order grid working. Still understanding what to do with the layout.
    =angelko

  19. 100% functional in magento 1.4.1.1

    But not in 1.4.2.0

    What modification is necessary, any see

  20. Very nice and informative tutorial! Do you already have some information about the 1.4.2-issues?
    In 1.4.2 the “sales_order_resource_init_virtual_grid_columns” is not fired.

    Thanks again!

  21. Hi again,

    I now got payment method column working, still having problem with company and customer email-adress. If someone got any suggestions to get this please let me know.

    I also wonder if its possible to set the column with in the layout xml file. Plus it would be nice to add a dropdown box for the payment column..
    Can this be done?

    Many thanks
    Johan

  22. Worked great, thanks. I added the shipping_description field. If you or anyone else knows how to make it a dropdown (as Johan suggested), that would be even better.

  23. ok after all files implementation how do I install the module? sorry but im new to magento…

  24. Thank you for the nice explanation, but do I have to use same technique while adding new attribute to Customer and adding new column for that attribute in Admin/Customer?

  25. Don’t bother answering the above question, I realized what the code is doing and I must admit, this is the best method I have seen so far from all about extending admin grids, it’s also the most elegant way without hacking the core.

  26. Hi Ivan,
    this is my sql setup

    <?php
    /**
     * Setup scripts, add new column and fulfills
     * its values to existing rows
     *
     */
    /* @var $this Mage_Sales_Model_Mysql4_Setup */
    $this->startSetup();
    // Add column to grid table
    $this->getConnection()->addColumn(
        $this->getTable('sales/order_grid'),
        'payment',
        "varchar(255) not null default ''"
    );
    // Add key to table for this field,
    // it will improve the speed of searching & sorting by the field
    $this->getConnection()->addKey(
        $this->getTable('sales/order_grid'),
        'payment',
        'payment'
    );
    // Now you need to fullfill existing rows with data from address table
    $select = $this->getConnection()->select();
    $select->join(
        array('order_payment'=>$this->getTable('sales/order_payment')),
        $this->getConnection()->quoteInto('order_payment.parent_id = order_grid.entity_id'),
        array('payment' => 'method')
    );
    $this->getConnection()->query(
        $select->crossUpdateFromSelect(
            array('order_grid' => $this->getTable('sales/order_grid'))
        )
    );
    $this->endSetup();
    ?>
    

    And

    <?php
    /**
     * Setup scripts, add new column and fulfills
     * its values to existing rows
     *
     */
    /* @var $this Mage_Sales_Model_Mysql4_Setup */
    $this->startSetup();
    // Add column to grid table
    $this->getConnection()->addColumn(
        $this->getTable('sales/order_grid'),
        'payment',
        "varchar(255) not null default ''"
    );
    // Add key to table for this field,
    // it will improve the speed of searching & sorting by the field
    $this->getConnection()->addKey(
        $this->getTable('sales/order_grid'),
        'payment',
        'payment'
    );
    // Now you need to fullfill existing rows with data from address table
    $select = $this->getConnection()->select();
    $select->join(
        array('order_payment'=>$this->getTable('sales/order_payment')),
        $this->getConnection()->quoteInto('order_payment.parent_id = order_grid.entity_id'),
        array('payment' => 'method')
    );
    $this->getConnection()->query(
        $select->crossUpdateFromSelect(
            array('order_grid' => $this->getTable('sales/order_grid'))
        )
    );
    $this->endSetup();
    ?>
    

    I did everything following you but
    no data display in the grid
    Could you help me please?

  27. Very nice and informative guide.
    i’m trying to play with your code.
    and…

    i’m just dropped customer_telephone field from sales_flat_order_grid table. and then after…

    i have a problem. when I place order in frontend it through the exception

    “Please specify a valid grid column alias name that exists in grid table.”

    if i remove your module, then checkout working fine.

  28. when i created customer_telephone field to sales_flat_order_grid table. and place order again…
    but problem still same…
    “Please specify a valid grid column alias name that exists in grid table.”

    how to reset for sales_flat_order_grid table… same like before…( when i install you module before…)
    and how remove your module data from mysql db?

  29. How can i display deal name to order_grid

  30. Hi Ivan… great tutorial and reference… I wonder if you have any reference on implementing a column with a type of “options” as opposed “text” and populating the options into the select menu that options creates… Thanks again

  31. I am interested how can I add a custom order attribute inside the order details page. The idea is to have a checkbox there saying it is escalated order and then when the Invoice is sent if this is ticked a special text to be displayed in the Invoice. I know how to add this inside the Invoice but how can i add this attribute on order details page.
    Thanks in advance.

  32. Edwin Koster says:

    Hi Ivan,

    thanks for this article. Ive used it to show customer email on order grid. But i’ve noticed when i only add the database column in installer script, and code to fill email field for existing orders everyting works fine.

    When i do an order now, the new order appears in the order grid including the email column.

    I was thinking the event observer part was to add the customer email to the grid table when a new order was placed, but it looks like i’m wrong.

    Can you give a little more explaination about when the event is fired?

    Thanks a lot!

    • Hi Edwin,

      If you use attribute from order entity you don’t need to define observer for addition virtual column, because this attribute exists in order table and will be fulfilled automatically on order save action. This event add instructions for order resource model from what place it should retrieve data for grid, after the order save action.
      See the last paragraph in the article.

  33. Edwin Koster says:

    By the way, it looks like all comments on this page are witten at the 27th of july.. (but i wrote mine today)
    I think it’s a little bug?

    • As for bug, yeah, seems the wordpress developer who created our theme used wrong function for date retrieval, so it showed post date with comment time, instead of comment time. I just fixed that small issue.

  34. Simon Young says:

    Hi Ivan

    This is really helpful. I’m trying to add the shipping description field to the grid. I have the column added and displayed but it’s not populating the old data from sales_flat_order. Where am I going wrong?

    Here is my SQL install file:

    <?php
    /**
     * Setup scripts, add new column and fulfills
     * its values to existing rows
     *
     */
    /* @var $this Mage_Sales_Model_Mysql4_Setup */
    $this->startSetup();
    // Add column to grid table
    $this->getConnection()->addColumn(
        $this->getTable('sales/order_grid'),
        'shipping_description',
        "varchar(255) not null default ''"
    );
    // Add key to table for this field,
    // it will improve the speed of searching & sorting by the field
    $this->getConnection()->addKey(
        $this->getTable('sales/order_grid'),
        'shipping_description',
        'shipping_description'
    );
    // fill existing rows with data
    $select = $this->getConnection()->select();
    $select->join(
        array('order'=>$this->getTable('sales/order')),
        $this->getConnection()->quoteInto('order.entity_id = order_grid.entity_id',''),
        array('shipping_description' => 'shipping_description')
    );
    $this->getConnection()->query(
        $select->crossUpdateFromSelect(
            array('order_grid' => $this->getTable('sales/order_grid'))
        )
    );
    $this->endSetup();
    

    Thanks!

    Simon

  35. Hi Ivan,

    Almost everything works, that is, I got my additional columns added to the table and filled with data. However, the grid is not updated. As mentioned earlier in another comment, the “sales_order_resource_init_virtual_grid_columns” doesn’t seem to fire, at least no in v1.5.1.0. I logged the dispatched events which are:

    2011-06-27T00:13:19+00:00 ALERT (1): resource_get_tablename(resource,model_entity,table_name)
    2011-06-27T00:13:19+00:00 ALERT (1): resource_get_tablename(resource,model_entity,table_name)
    2011-06-27T00:13:19+00:00 ALERT (1): resource_get_tablename(resource,model_entity,table_name)
    2011-06-27T00:13:19+00:00 ALERT (1): resource_get_tablename(resource,model_entity,table_name)
    2011-06-27T00:13:19+00:00 ALERT (1): resource_get_tablename(resource,model_entity,table_name)
    2011-06-27T00:13:19+00:00 ALERT (1): resource_get_tablename(resource,model_entity,table_name)
    2011-06-27T00:13:19+00:00 ALERT (1): core_collection_abstract_load_before(collection)
    2011-06-27T00:13:19+00:00 ALERT (1): core_collection_abstract_load_after(collection)
    2011-06-27T00:13:19+00:00 ALERT (1): core_collection_abstract_load_before(collection)
    2011-06-27T00:13:19+00:00 ALERT (1): core_collection_abstract_load_after(collection)
    2011-06-27T00:13:19+00:00 ALERT (1): core_collection_abstract_load_before(collection)
    2011-06-27T00:13:19+00:00 ALERT (1): core_collection_abstract_load_after(collection)
    

    Any comment HIGHLY appreciated. Many thanks.

  36. Please disregard my above post. The event does fire after all. It was a typo in my xml file that caused the situation. Sorry for any inconvenience or trouble, and thank you so much for the great articles and sharing of insight in Magento’s code and functionality.

  37. Would you by any chance know if there is an opposite method to addVirtualColumn, such as removeVirtualColumn, or alike?

    I have added to columns, ‘Bill to Company’ and ‘Ship to Company’, and would like remove the standard ‘Bill to Name’ and ‘Ship to Name’ columns. I have found that these standard columns are hardcoded in Mage_Sales_Model_Mysql4_Order. Do I have to bypass this class by adding my own in my module, or is there as smarter way?

    • addVirtualColumn used only in saving order process, when records for grid table are generated. You should look into grid block columns logic:
      For your purpose it is better just perform one more addColumn with the same column id as ship to name and bill to name but with different ‘index’ where your new column names will be.

  38. Ivan,
    Great tutorial you’ve provided. I’m looking for this functionality overall, but the column I’d like to add is for that of a custom product attribute.

    I was thinking I could use the joinAttribute function to pull that attribute for the product/sku that’s been ordered, but first off I’m not exactly sure what the code should look like, and second, the ordering of multiple products for an order may cause some problems.

    Any ideas on how to approach this… or how the code might look?

    Thanks!
    Brian

  39. mzentrale says:

    hi,

    great tutorial, big up!

  40. Hi,
    This is very nice article.can u explain the same steps for adding phone number column in magento 1.5.But,It is not working.I means phone number is not being displayed on the sales order grid.
    Adding order attribute to the orders grid in Magento 1.5

    Thanks

  41. Hi, Ivan!
    And how to add a column with “options” type and options given by some model?

  42. Great article, works well. Thanks!

  43. I am trying to apply this same principal to create a delivery date field in the grid and a ship date field in the grid. The delivery Date generates they date that customer chooses for shipping… the ship date is suppose to reflect a when the package is released from the warehouse I have tried and failed miserable at this can create a grid column but maybe you may know of better method of calling out something like this

  44. Sergey A. Lisenko says:

    Hey, Ivan!
    Thanks again for another one good Magento solution.
    But i’m not sure that changing of Magento Core tables is a good idea. Please, let me suggest another one solution for the same task.
    I’ve created new simple module and added new table `my_order_phone`, that has joined to sales/order_grid table through `increment_id` field.
    Next step – override Magento Core Block.

    <?xml version="1.0"?>
    <config>
    ....
    	<global>
    		<blocks>
    			<adminhtml>
    				<rewrite>
    					<sales_order_grid>My_Module_Block_Mage_Adminhtml_Sales_Order_Grid</sales_order_grid>
    				</rewrite>
    			</adminhtml>
    		</blocks>
    	</global>
    ....
    </config>
    

    In class My_Module_Block_Mage_Adminhtml_Sales_Order_Grid, that extended Mage_Adminhtml_Block_Sales_Order_Grid i’ve overrided ‘_prepareCollection’ and ‘_prepareColumns’ methods to add needed join to the my table and add new column to the grid, with custom renderer if needed.
    Last step – add an observer to save extended data after saving an order.

    	<frontend>
    		<events>
    			<sales_order_save_after>
    				<observers>
    					<rushorder_model_observer>
    						<type>singleton</type>
    						<class>rushorder/observer</class>
    						<method>rushAnOrder</method>
    					</rushorder_model_observer>
    				</observers>
    			</sales_order_save_after>
    		</events>
    	</frontend>
    
  45. Thanks for such info , how can we get the product thumbnails in sales order grid ?

    Thanks again

  46. Great Tutorial! This worked like a charm.

    Quick Question – how do you get the newly added columns to show when you export as .csv? Is there a special function for exporting that also needs to be modified?

    Thanks again! This is great stuff.

  47. I found a way that works but might not be the best solution:

    I modified the file here: app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php (I think the whole point of this is to not have to modify this file)

    Added the following:

    /* NJC Custom Columns */
    	    $this->addColumn('license_total', array(
                'header' => Mage::helper('sales')->__('License Fee'),
                'index' => 'license_total',
    			'type'  => 'currency',
                'currency' => 'order_currency_code',
            ));
    		$this->addColumn('convenience_fee', array(
                'header' => Mage::helper('sales')->__('Convenience Fee'),
                'index' => 'convenience_fee',
    			'type'  => 'currency',
                'currency' => 'order_currency_code',
            ));
    		$this->addColumn('postage', array(
                'header' => Mage::helper('sales')->__('Postage'),
                'index' => 'postage',
    			'type'  => 'currency',
                'currency' => 'order_currency_code',
            ));
    		/* End Custom Columns */
    

    Now the columns come out in the .csv export as desired.

    Is there a better way to accomplish this?

    Thanks, hopefully this helps someone.

  48. I really agree with Ivan regarding this great approach of using event-observer method. I know it can be done using Adminhtml > Sales > Order Grid Overriding but what if some other extension overrides that Block? Who wins the battle? :)
    It’s always good to use event-observer method whenever possible. Magento should provide as much as events for the purpose.

    Thanks Ivan for the great post and sharing with us.

    Cheers!!

  49. Ivan, I really need your help in the case that i was unable to make the added custom columns in the csv export. Is there any xml config for that?
    Let me know.

    Thanks
    Regards

  50. DigitalDeath says:

    I’m need to add a column with the country and another with the province/state instead of the phone number on 1.5.1
    Anything I should be aware of for 1.5.1 or some ideas I should be aware of?

    Thanks :)

  51. Hi,
    I followed this code . I have a custom module named “subscription” .I am trying to place subscription start date in sales admin grid.In ” Config.xml ” i putbelow code:-

    0.1.0

    <!–

    Subscription_Start_Model

    –>

    Subscription_Start_Model

    Mage_Sales_Model_Mysql4

    sales_flat_order_grid

    subscription_start/observer
    addColumnToResource

    Subscription_Start
    Mage_Sales_Model_Mysql4_Setup

    subscription/start.xml

    Subscription_Start_Model_Mysql4

    sales_flat_order_grid

    Observer.php:-

    public function addColumnToResource(Varien_Event_Observer $observer)
    {
    /* @var $resource Mage_Sales_Model_Mysql4_Order */
    $resource = $observer->getEvent()->getResource();
    $resource->addVirtualGridColumn(
    ‘subscription_start_date’,
    ‘subscription’,
    array(” => ”),
    ‘start_date’
    );
    }

    in sql file:–

    $this->startSetup();
    // Add column to grid table
    $this->getConnection()->addColumn(
    $this->getTable(‘sales/order_grid’),
    ‘subscription_start_date’,
    ‘datetime NULL’
    );
    // Add key to table for this field,
    // it will improve the speed of searching & sorting by the field
    $this->getConnection()->addKey(
    $this->getTable(‘sales/order_grid’),
    ‘subscription_start_date’,
    ‘subscription_start_date’
    );
    // Now you need to fullfill existing rows with data from address table
    $select = $this->getConnection()->select();
    $select->join(
    array(‘subscription’=>$this->getTable(‘subscription’)),
    $this->getConnection()->quoteInto(‘subscription.subscription_id = order_grid.entity_id ‘//, Mage_Sales_Model_Quote_Address::TYPE_BILLING
    ),
    array(‘subscription_start_date’ => ‘start_date’)
    );
    $this->getConnection()->query(
    $select->crossUpdateFromSelect(
    array(‘order_grid’ => $this->getTable(‘sales/order_grid’))
    )
    );
    $this->endSetup();$this->startSetup();
    // Add column to grid table
    $this->getConnection()->addColumn(
    $this->getTable(‘sales/order_grid’),
    ‘subscription_start_date’,
    ‘datetime NULL’
    );
    // Add key to table for this field,
    // it will improve the speed of searching & sorting by the field
    $this->getConnection()->addKey(
    $this->getTable(‘sales/order_grid’),
    ‘subscription_start_date’,
    ‘subscription_start_date’
    );
    // Now you need to fullfill existing rows with data from address table
    $select = $this->getConnection()->select();
    $select->join(
    array(‘subscription’=>$this->getTable(‘subscription’)),
    $this->getConnection()->quoteInto(‘subscription.subscription_id = order_grid.entity_id ‘//, Mage_Sales_Model_Quote_Address::TYPE_BILLING
    ),
    array(‘subscription_start_date’ => ‘start_date’)
    );
    $this->getConnection()->query(
    $select->crossUpdateFromSelect(
    array(‘order_grid’ => $this->getTable(‘sales/order_grid’))
    )
    );
    $this->endSetup();

    Field is created but value is not coming .Please help me. It’s very urgent for me.

    Thanks,
    Swapna.

  52. How to add column “Product name” and “Email” “Quantity” in Oder list?. Help me!. Thanks!.

  53. I am running this code successfully.

    i have add the customer email in place of telephone.

    it give me this error when i try to edit the order

    SQLSTATE[42000]: Syntax error or access violation: 1110 Column ‘customer_email’ specified twice

  54. Does this tutorial work for Magento 1.6++?

  55. I am having some issues and errors with this. “exception ‘Mage_Core_Exception’ with message ‘Please specify a valid grid column alias name that exists in grid table.’ in”

    I need to bring in three columns.
    cc_type with dropdown filter
    base_tax_amount as currency
    subtotal before tax as currency

    I have tried many ways but I am still not able to get this working.

  56. I got it but like others the newly created fields do not export when you click on export to CSV. Is there any way to make this do that?

  57. Hello

    I need to create a new column in the grid order of Magento, but I need the value to be read in a MySQL table I created separately.
    This table has a field that identifies the request, and with a value that I wish to present new field in the grid.
    I can do this from the model presented in this article?
    That is, create a way to “read” the table I created, identify the application number, and return the desired value?

    Any help or tip is welcome.

    Thank you.

    Homero Ottoni

  58. Hello

    I need to change the status of the application in the the screen grid, after the invoices are printed. The client needs to check claims to have invoices printed from this screen. So I created a separate table, to manage this situation.

    But I do not know how to present the status of whether or not printed on the grid order, you know a way to do this directly by the system of Magento?

    The printing of the bill changes a field in the tables in Magento?

    Thank you.

  59. I need to add Category name column in order detail page items section. plus i need to make sortable columns there… any one help me thanks in advance

  60. Hello,

    This is really nice tutorial.

    We are developing our project in magento 1st time for for gadgets and mobile selling.

    So when we create invoice for particular order at that time I should be able to update/enter the (IMEI)number for particular invoice.
    and show in invoice.

    (we need to add custom field when we create Invoice for Order )

    pls help me for this task..

  61. What would be the call for adding a role but going off a user base login.

    Like it shows the user that made the sale
    i already setup my sales guys with their own logins and all they are able to do is make invoices for customers. But whn i login i would like to beable to see on my screen in the orders tabe the person that made the sale.

    I get the sets All im unsure about is how to getit to call the user based on sale

  62. hi-

    is there a way to have the new field included when you export to CSV?

  63. This is awesome!!! > Fully functional in 1.7 . Just did it :)

  64. Hi Ivan,
    This module is awesome. I’ve added payment method with your code in 1.6.2.
    But, it show payment method code, what I want is payment method title.
    Ivan, can you help me, how I can display payment method title?
    thx :)

  65. Custom options and render for column can be added in XML.

  66. Mohammad Rehan says:

    hi! how to add custom field city or country on Sales >> Order…? in Magento Admin panel.. Please give me solution .. Thanks

  67. Hi!! How to add custom field City or Country in Sales >> Order on Magento admin panel.. plz. give me solution.. Thanks.

  68. Hi,

    Is this way the search is working properly?

  69. Hi,
    i am really say lot of thanks ,Ivan Chepurnyi i wants to add a Product_id field can u tell me how to insert the selected product_id in this field…??

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>