This question already has an answer here:

i am try to add columns in Admin > sales >order by overriding method. Copy app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php to app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php.

add this code in protected function _prepareCollection()

$collection->getSelect()->join('sales_flat_order_item', '`sales_flat_order_item`.order_id=`main_table`.entity_id', array('name'  => new Zend_Db_Expr('group_concat(`sales_flat_order_item`.name SEPARATOR ", ")')));

add this code in protected function _prepareColumns()

$this->addColumn('name', array(
        'header' => Mage::helper('sales')->__('Product Name'),
        'index' => 'name',

but it get all get all product's name of all orders like in the image enter image description here

marked as duplicate by David Manners, Keyul Shah, Marius, Anna Völkl, Fabian Blechschmidt Oct 30 '14 at 15:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • What are you trying to accomplish? group_concat(sales_flat_order_item.name SEPARATOR ", ") will display all item order as name – Renon Stewart Oct 30 '14 at 12:01
  • @R.S i don't understanding u waht u want to say – Dinesh Oct 30 '14 at 12:04

Take look at Show SKU and Product Name in Sales_Order_Grid?

You can do this one of two ways :

1) Using "renderer"

$this->addColumn('name', array(
    'renderer' => 'NameSpace_ModuleName_Block_Adminhtml_Renderer_Productsname',          

class NameSpace_ModuleName_Block_Adminhtml_Renderer_Productsname extends     Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
    public function render(Varien_Object $row)

        foreach($order->getAllVisibleItems() as $_item){                      
            $str .= $_item->getSku();
        return $str;

2) using "join" see https://magento.stackexchange.com/a/14343/519

  • at which location, I have to create a render file and with which name ? – Dinesh Oct 30 '14 at 13:33
  • You seem to be making changes to core (which you should not) instead create a custom module see inchoo.net/magento/programming-magento/… and inchoo.net/magento/… – Renon Stewart Oct 30 '14 at 13:42
  • no i am not editing core file, i am overriding core file by Copy /app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php to /app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php. – Dinesh Oct 31 '14 at 5:16
  • i am using render method with this code class Mage_Adminhtml_Block_Sales_Order_Renderer_Productsname extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract { public function render(Varien_Object $row) { $order=Mage::getModel('sales/order')->load($row->getData('entity_id')); $str=""; foreach($order->getAllItems() as $_item){ $str .= $_item->getSku(); } unset($order); return $str; } } but it repeat last product two times – Dinesh Oct 31 '14 at 7:03
  • Update your question with your code in a readable format – Renon Stewart Oct 31 '14 at 14:31

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