2017-08-16 133 views
0

我添加了一個客戶管理列表格稱爲「LAST_LOGIN」爲獲得客戶上次登錄time.it列工作perfect.But而filteing上次登錄時間我收到錯誤page.Here是我的代碼「LAST_LOGIN」 colomn客戶管理網格

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,*/ 
     )); 

回答