Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected function _prepareCollection()
- {
- $collection = Mage::getResourceModel('customer/customer_collection')
- ->addNameToSelect()
- ->addAttributeToSelect('email')
- ->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');
- $collection->addAttributeToSelect('salesrep');
- parent::setCollection($collection);
- // GET LAST ORDER DATE
- $sql ='SELECT MAX(o.created_at)'
- . ' FROM ' . Mage::getSingleton('core/resource')->getTableName('sales/order') . ' AS o'
- . ' WHERE o.customer_id = e.entity_id ';
- $expr = new Zend_Db_Expr('(' . $sql . ')');
- $collection->getSelect()->from(null, array('last_order_date'=>$expr));
- $this->setCollection($collection);
- return parent::_prepareCollection();
- }
- protected function _prepareColumns()
- {
- ...
- $this->addColumn('last_order_date', array(
- 'header' => Mage::helper('customer')->__('Last Order Date'),
- 'type' => 'datetime',
- 'align' => 'left',
- 'index' => 'last_order_date',
- 'gmtoffset' => true
- ));
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement