Magento : Product Name and Product SKU in Sales order grid

Product Name and Product SKU in Sales order grid: This is really very important and needed aspects of the sales order grid and saves a lot of time of your’s , Lot of users requested us for this tutorial . so here is a simple hack to display product order name and product sku in magento sales order grid .

Go to /app/code/core/Mage/Adminhtml/Block/Sales/Order and open grid.php

Now replace your _prepareCollection() function to this following code

protected function _prepareCollection()
    {
       	$collection = Mage::getResourceModel($this->_getCollectionClass())
		    ->join(
		        'sales/order_item',
		        '`sales/order_item`.order_id=`main_table`.entity_id',
		        array(
		            'skus'  => new Zend_Db_Expr('group_concat(`sales/order_item`.sku SEPARATOR ",")'),
		            'names' => new Zend_Db_Expr('group_concat(`sales/order_item`.name SEPARATOR ",")'),
		            )
		        );
		        $collection->getSelect()->group('entity_id');

		    $this->setCollection($collection);
        return parent::_prepareCollection();
    }

After adding this function lets add the columns in grid for sku and ordername add this code in your _prepareColumns() function

$this->addColumn('skus', array(
            'header'    => Mage::helper('Sales')->__('Skus'),
            'width'     => '100px',
            'index'     => 'skus',
            'type'        => 'text',

        ));
	$this->addColumn('names', array(
            'header'    => Mage::helper('Sales')->__('Name'),
            'width'     => '100px',
            'index'     => 'names',
            'type'        => 'text',

after this you’ll display your sales order screen in like this Email me for any query or suggestion : sahu.vipin@webkul.com
We also provide extended version of the module for magento extended sales order grid .

This module supports following product properties in sales order grid –

★ Product image

★ Product id

★ SKU

★ Product Name

★ Buyer Email address

★ Gender

★ Ordered Quantity

Feel free to contact us  or add a ticket at our ticket support system – http://webkul.com/ticket/index.php

. . .

Comments (2)

Add Your Comment

  • Paolo L
    get error 500 during “add this code in your _prepareColumns() function” section.
  • yoseph2012
    Thank you! It shows the SKUs and names perfectly. But when trying to search for specific SKU, it throws error saying: Column not found: 1054 Unknown column ‘skus’ in ‘where clause’.. Can you help?
  • css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close