You need column renderer functionality, here is just basic idea how you can do it, (this code is not tested) -
in your module you need to use renderer
param in file extendedgrid.xml
like below --
<action method="addColumnAfter">
<columnId>payment_method</columnId>
<arguments>
<header>Payment Method</header>
<index>payment_method</index>
<filter_index>payment.method</filter_index>
<renderer>Atwix_ExtendedGrid_Block_Adminhtml_Sales_Order_Grid_Renderer</renderer>
<type>text</type>
</arguments>
<after>shipping_name</after>
</action>
and create file 'Renderer.php' at path Atwix/ExtendedGrid/Block/Adminhtml/Sales/Order/Grid
<?php
class Atwix_ExtendedGrid_Block_Adminhtml_Sales_Order_Grid_Renderer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
public function render(Varien_Object $row)
{
$paymentMethodCode = $row->getData($this->getColumn()->getIndex());
/* $payments = Mage::getSingleton('payment/config')->getActiveMethods(); // will get all active payment method*/
$payments = Mage::getModel('payment/config')->getAllMethods(); // get all available payment method
$paymentTitle = '';
foreach ($payments as $paymentCode=>$paymentModel)
{
if($paymentMethodCode == $paymentCode)
{
$paymentTitle =Mage::getStoreConfig('payment/'.$paymentCode.'/title');
}
}
return $paymentTitle;
}
}
Reference link for renderer functionality :-
http://www.justwebdevelopment.com/blog/add-custom-column-and-get-custom-renderer-value-in-magento-grid/
http://magento.ikantam.com/qa/how-add-custom-renderer-magento-grid
EDIT:- in case if you use block file instead of layout file for column in grid, use below function to apply filter on renderer
column.
public function filterPaymentMethod($collection, $column)
{
if (!$value = $column->getFilter()->getValue()) {
return $this;
}
$collection->getSelect()->join(
'sales_flat_order_payment',
'main_table.entity_id = sales_flat_order_payment.parent_id',
array('method'))
->where("sales_flat_order_payment.method like ?", "%$value%");
return $collection;
}
Edit2:- replace your function filterPaymentMethod
in observer.php
file with below code --
public function filterPaymentMethod($collection, $column)
{
if (!$value = $column->getFilter()->getValue()) {
return $this;
}
$payments = Mage::getSingleton('payment/config')->getAllMethods();
$codeToFilter ='';
foreach ($payments as $paymentCode=>$paymentModel) {
$paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
if (stripos($paymentTitle, $value) !== false && !$codeTomatch) {
$codeTomatch = $paymentCode;
}
}
$collection->getSelect()->join(
'sales_flat_order_payment',
'main_table.entity_id = sales_flat_order_payment.parent_id',
array('method'))
->where("sales_flat_order_payment.method like ?", "%$codeToFilter%");
return $collection;
}
additional_information
column instead ofmethod
column. in this column payment title is saved like - {"method_title":"Check \/ Money order"}$select->joinLeft(array('payment' => $collection->getTable('sales/order_payment')), 'payment.parent_id=main_table.entity_id', array('method_title' => 'additional_information'));