i write a Magento grid extend Mage_Adminhtml_Block_Widget_Grid, for custom Manage Customers page. I need sort multiple columns by default, then i write _prepareCollection method:
protected function _prepareCollection()
{
$collection = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect()
->addAttributeToSelect('customer_type')
->addAttributeToSelect('email')
->addAttributeToSelect('created_at')
->addAttributeToSelect('group_id')
->addAttributeToSelect('customer_status')
->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left')
->addAttributeToSort('customer_status', 'asc')
->addAttributeToSort('customer_type', 'asc');
$this->setCollection($collection);
return parent::_prepareCollection();
}
Note that customer_status and customer_type are attributes. But it does not work. I need help, thanks.