Magento – Payment Method Sales/Order grid – Magento 1.9

magento-1.9order-gridpayment-methods

We load the following code to show the payment method inside the Sales/Order grid.

But this displays the payment code and we want to display the payment title.

How can we change our current code to show the title?

CODE:

$select->joinLeft(array('payment' => $collection->getTable('sales/order_payment')), 'payment.parent_id=main_table.entity_id', array('payment_method' => 'method'));

CODE filterPaymentMethod:

public function filterPaymentMethod($collection, $column)
{
    if (!$value = $column->getFilter()->getValue()) {
        return $this;
    }

    $collection->getSelect()->having(
        "group_concat(`sales_flat_order_item`.sku SEPARATOR ', ') like ?", "%$value%");

    return;
}

Best Answer

Try below way

you can use like this to get the payment method in your custom module or override core files /app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php

protected function _prepareCollection()
    {
         $collection = Mage::getResourceModel($this->_getCollectionClass());
         $collection->join(array('payment'=>'sales/order_payment'),'main_table.entity_id=parent_id','method');
         $this->setCollection($collection);
         return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
         // end here //
    }

and in grid

 protected function _prepareColumns()
    {

 $payments = Mage::getSingleton('payment/config')->getActiveMethods();

        $methods = array();
        foreach ($payments as $paymentCode=>$paymentModel)
        {
                $paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
                $methods[$paymentCode] = $paymentTitle;
        }

        $this->addColumn('method', array(
                'header' => Mage::helper('sales')->__('Payment Method'),
                        'index' => 'method',
                        'filter_index' => 'payment.method',
                        'type'  => 'options',
                        'width' => '70px',
                        'options' => $methods,
                ));
        // End here
    }

hope this will work for you

Related Topic