i’ve tried to add a column for Customer Group on Adminhtml_Block_Sales_Order_Grid.
And was partially successful, the only issue i’am having atm is that the column is empty if the Order was done by an Guest Customer.
My code:
<?php
class MyNamespace_CustomizeGrids_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
{
protected function _prepareColumns() {
$groups = Mage::getResourceModel('customer/group_collection')
->addFieldToFilter('customer_group_id', array('gt' => 0))
->load()
->toOptionHash();
$groups[0] = "Guest";
$this->addColumn('customer_group_id', array(
'header' => Mage::helper('customer')->__('Customer Group'),
'width' => '100',
'index' => 'customer_group_id',
'type' => 'options',
'options' => $groups,
));
$this->addColumnsOrder('customer_group_id', 'shipping_name');
return parent::_prepareColumns();
}
}
As you can see i fixxed this issue through manipulating the $groups array.
My question is: Is there a better way to do this?
For Guest, in Magento, the
customer_group_idis0(NOT LOGGED IN)In your query, you are saying magento to get all the groups which are GREATER THAN 0
array('gt' => 0)You can fix this by using:
instead of