,而不是你的性別代碼,把這個:
$genders = $this->_getGenderOptions();
$this->addColumn('gender', array(
'header' => Mage::helper('customer')->__('Gender'),
'index' => 'gender',
'type' => 'options',
'options' => $genders
));
然後,在網格類中創建新的方法:
private function _getGenderOptions()
{
$options = Mage::getResourceSingleton('customer/customer')->getAttribute('gender')->getSource()->getAllOptions();
$array = array();
foreach ($options as $option)
{
if($option['label'] == "")
continue;
$array[$option['value']] = $option['label'];
}
return $array;
}
,並在方法
protected function _prepareCollection();
通過添加加載收藏:
->addAttributeToSelect('dob')
->addAttributeToSelect('gender')
它應該看起來像:
$collection = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect()
->addAttributeToSelect('email')
->addAttributeToSelect('dob') // new code
->addAttributeToSelect('gender') // new code
->addAttributeToSelect('created_at')
->addAttributeToSelect('group_id')
->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');
,這就是它!
謝謝作品幫我 – 2014-10-10 07:50:20
歡迎您! – 2014-10-10 07:51:06