Php Magento自定义管理网格页面中的默认多个排序列

Php Magento自定义管理网格页面中的默认多个排序列,php,magento,Php,Magento,我编写了一个Magento网格扩展Mage_Adminhtml_Block_Widget_网格,用于自定义管理客户页面。 默认情况下,我需要对多个列进行排序,然后我编写_prepareCollectionmethod: protected function _prepareCollection() { $collection = Mage::getResourceModel('customer/customer_collection') ->addNameToS

我编写了一个Magento网格扩展Mage_Adminhtml_Block_Widget_网格,用于自定义管理客户页面。 默认情况下,我需要对多个列进行排序,然后我编写_prepareCollectionmethod:

    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();
  }
请注意,customer_status和customer_type是属性。 但它不起作用。我需要帮助,谢谢。

您可以使用下面的代码

$collection->setOrder(array('customer_status', 'customer_type'), asc);