====== Sort Orders by Customer Groups ====== ==== Overview ==== This is a quick tutorial on how to sort orders by Customer Group in the "admin/sales_order/" section. I really had a hard time figuring it out so I thought I would share my experience. ==== Step 1 ==== Go to /app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php and add the following code in the _prepareColumns() method (around line 60): $this->addColumn('customer_group_id', array( 'header'=> Mage::helper('customer')->__('Customer Group'), 'width' => '80px', 'index' => 'customer_group_id', 'renderer' => new Mage_Adminhtml_Block_Sales_Order_Renderer_CustomerGroup(), 'type' => 'options', 'options' => Mage_Adminhtml_Block_Sales_Order_Renderer_CustomerGroup::getCustomerGroupsArray(), )); ==== Step 2 ==== We now need to create our renderer class which will transform group IDs into apropriate labels: Create the following file: /app/code/core/Mage/Adminhtml/Block/Sales/Order/Renderer/CustomerGroup.php (you'll also have to create the Renderer directory) and put the following code in it: getCollection()->toOptionHash(); self::$_customerGroups = $customer_groups; } return self::$_customerGroups; } // Transforms the customer_group_id into corresponding label public function render(Varien_Object $row) { $val = $this->_getValue($row); $customer_groups = self::getCustomerGroupsArray(); return isset($customer_groups[$val]) ? $customer_groups[$val] : false; } } ==== Step 3 ==== You can now visualize/sort your orders by customer groups. ==== Tested version(s) ==== Magento 1.0