I have a module that adds a payment method column to the Sales > Orders grid.
$this->addColumn('method', array(
'header' => Mage::helper('sales')->__('Payment<br />Method'),
'index' => 'method',
'renderer' => 'Artizara_Ordergridadditions_Block_Catalog_Product_Renderer_Payment',
'filter_index' => 'sfop.method', // refers to a declaration above
type' => 'options',
'options' => array(0=>'Option 1',1=>'Option2'), // how would I get the keys to match to the renderer options???
));
Renderer code (below):
public function render(Varien_Object $row) {
$value = $row->getData($this->getColumn()->getIndex());
switch ($value) {
case 'authorizenet':
$value = 'Credit Card (Authorize.net)';
$span = '';
break;
case 'paypal_express':
$value = 'Paypal Express';
$span = '';
break;
case 'checkmo':
$value = 'Check/Money Order';
$span = '';
break;
case 'free':
$value = 'No Payment Required';
$span = '';
break;
default:
$value = 'Unknow Payment Method';
$span = 'style="color:red;"';
}
return '<span ' . $span . '>' . $value . '</span>';
}
Simply want to be able to make a dropdown prepopulated with the renderer options for filtering in the grid.
Note: If I add the text field method for filtering, you have to put in the original keys from the database (e.g. - checkmo, paypal_express, authorizenet, etc).
I'd like to be able to show the renderer values for each in the dropdown...(how)?
EDIT 7/20/12
I've tried two following ways below but not working yet...
'options' => array(
array('value' => 'authorizenet', 'label' => 'Credit Card (Authorize.net)'),
array('value' => 'paypal_express', 'label' => 'Paypal Express'),
array('value' => 'checkmo', 'label' => 'Check/Money Order'),
array('value' => 'free', 'label' => 'No Payment Required'),
),
Just gets me a dropdown populated with 4 options as follows:
Array
Array
Array
Array
I've tried it also like this:
'options' => array(
array => ('value' => 'authorizenet', 'label' => 'Credit Card (Authorize.net)'),
array => ('value' => 'paypal_express', 'label' => 'Paypal Express'),
array => ('value' => 'checkmo', 'label' => 'Check/Money Order'),
array => ('value' => 'free', 'label' => 'No Payment Required'),
),
But I get an error:
Parse error: syntax error, unexpected T_DOUBLE_ARROW, expecting '('
Use an option hash with the values you use in your renderer :
'options' => array(
'authorizenet' => 'Credit Card (Authorize.net)',
[..]
)
On a side note, you may be interested by the Enhanced Admin Grids
extension I develop (page on Magento Connect), the latest version available on github has brought a custom columns system that allows to add new columns without rewrites and with quite some possibilities.
And as a basis, it comes with a payment method column for the orders grid.