我在客户管理列表网格中添加了一个名为'last_login'的列,用于获取客户上次登录时间。这是完美的工作。但是在过去上次登录时我收到错误页面。这是我的代码
Grid.php
protected function _prepareCollection()
{
$collection = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect()
->addAttributeToSelect('type_of_customer')
->addAttributeToSelect('customer_unique_id')
->addAttributeToSelect('email')
->addAttributeToSelect('company')
->addAttributeToSelect('restaurant')
->addAttributeToSelect('created_at')
->addAttributeToSelect('last_login')
->addAttributeToSelect('group_id')
->addAttributeToSelect('mobile')
->addAttributeToSelect('membership_plan_id')
->addAttributeToSelect('admin_verification_status')
->addAttributeToSelect('mobile_verified')
->addAttributeToSelect('confirmation')
->addAttributeToSelect('nationality')
->addAttributeToSelect('enable_user')
->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');
$sql = '(SELECT MAX(logout_at) FROM log_customer WHERE log_customer.customer_id = e.entity_id GROUP BY log_customer.customer_id)';
$collection->getSelect()->columns(array('last_login' => new Zend_Db_Expr($sql)));
$collection->getSelect()->where(new Zend_Db_Expr("(e.type_of_customer = '0')"));
$this->setCollection($collection);
Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
foreach ($collection as $item){
$item->setData('email_conf',$item->getConfirmation()?'Not Verified':'Verified');
}
return ;
}
$this->addColumn('last_login', array(
'header' => Mage::helper('customer')->__('Last Login'),
'type' => 'datetime',
'align' => 'center',
'index' => 'last_login',
'gmtoffset' => true,
/*'filter' => false,
'sort' => false,*/
));
答案 0 :(得分:0)
//尝试使用以下代码并检查。
$this->addColumn('last_login',
array(
....
'filter_condition_callback' => array($this, '_filterLastLogin'),
));