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

4
  • add customer group column in order grid right ?? Commented Dec 10, 2019 at 13:56
  • yes, that is right
    – daniel
    Commented Dec 10, 2019 at 13:57
  • in magento 1.8 ??? Commented Dec 10, 2019 at 13:58
  • yes, that is right
    – daniel
    Commented Dec 10, 2019 at 14:01

1 Answer 1

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, ));

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.