Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Custom Column in Manage Customers Grid
 
keyzo
Jr. Member
 
Total Posts:  23
Joined:  2011-02-12
 

In the admin area of Manage Customers.

I’ve added a new custom column, BUT it doesn’t filter and it is not sortable either asc / desc

Here is my code

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->getSelect()->columns(array(’CustomerStatus’ => new Zend_Db_Expr ("(SELECT
CustomerStatusFROM users WHERE MagentoID =e.entity_id)")));

$this->setCollection($collection);

return parent::_prepareCollection();
}

I’ve tried loads of different methods and adding _addColumnFilterToCollection but just can’t seem to get it to work…

protected function _addColumnFilterToCollection($column)
{


if ($column->getId() == ‘CustomerStatus’ && $column->getFilter()->getValue()) {
$val = $column->getFilter()->getValue();


$this->getCollection()->addFieldToFilter(’CustomerStatus’, array(’like’ => $val));

// $this->getCollection()->getSelect()->where(’CustomerStatus= ?’, $val);

}

return $this;



}

Then this is how I’ve added my column within _preparecolumns funtion

$this->addColumn(’CustomerStatus’, array(
‘header’ => Mage::helper(’customer’)->__(’C Status’),
‘width’ => ‘100px’,
‘index’ => ‘CustomerStatus’,
‘filter_index’ => ‘CustomerStatus’
));

Any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top