Reputation: 225
I’m trying to add select in my column “Sources” to allow filter, all this code works well, but I’m trying to add filter without any success, anyone can point me in the right direction?
Until know I have:
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('source', 'customer/source', 'default_billing', null, 'left')
->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left');
$this->setCollection($collection);
return parent::_prepareCollection();
}
and
$this->addColumn('source', array(
'header' => Mage::helper('customer')->__('Source'),
'type' => 'source',
'index' => 'source'
));
Any help will be very apreciated thanks
Upvotes: 2
Views: 3352
Reputation: 225
I found the solution for transform in a Select option:
$sql = 'SELECT distinct value FROM `....';
$data = Mage::getSingleton('core/resource') ->getConnection('core_read')->fetchAll($sql);
$soTypes=array();
foreach($data as $array){
foreach($array as $key => $value){
if(!empty($value)){
$so[$value]=$value;
}
}
}
$this->addColumn('invoice_so', array(
'header' => Mage::helper('sales')->__('SoTypes'),
'index' => 'value',
'width' => '100px',
'type' => 'options',
'options' => $soTypes,
));
Upvotes: 2
Reputation: 37700
The type value should not be source
. That doesn't do anything. It needs to be one of the classes in app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/
.
- Checkbox
- Country
- Date
- Datetime
- Massaction
- Price
- Radio
- Range
- Select
- Store
- Text
- Theme
Upvotes: 0