1

I want to add a column in Sales > Order Grid for "Customer Group" after the "Ship to name" column. I know i need to modify

app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php

Could someone please help me with the proper code? Also, i don't want to build a custom module for this column. Thank you!

Using Magento 1.8

  • add customer group column in order grid right ?? – Rk Rathod Dec 10 '19 at 13:56
  • yes, that is right – daniel Dec 10 '19 at 13:57
  • in magento 1.8 ??? – Rk Rathod Dec 10 '19 at 13:58
  • yes, that is right – daniel Dec 10 '19 at 14:01
0

Magento 1 customer group id stored in sales_flat_order table while admin order grid fetch collection from sales_flat_order_grid so for getting customer group information must get data from sales_flat_order table.
magento order grid collection & column manage from app/code/core/Mage/Adminhtml\Block/Sales/Order/Grid.php so first join table in _prepareCollection() function as below.

$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->getSelect()->joinLeft(
    'sales_flat_order',
    'main_table.entity_id = sales_flat_order.entity_id',
    array('customer_group_id')
);
$this->setCollection($collection);
now add customer group column in grid with drop-down option as below (add this in _prepareColumns() function)
$groups = Mage::getResourceModel('customer/group_collection')
    ->addFieldToFilter('customer_group_id', array('gt'=> 0))
    ->load()
    ->toOptionHash();

$this->addColumn('customer_group_id', array( 'header' => Mage::helper('customer')->__('Group'), 'index' => 'customer_group_id', 'filter_index' => 'sales_flat_order.customer_group_id', 'type' => 'options', 'options' => $groups, ));

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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