0

I am tring to add payment method custom column in admin > sales > order with overriding core file by

Copying

 /app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php 

to

 /app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php.

with following code

$collection->getSelect()->join('sales_flat_order_payment', 'main_table.entity_id = sales_flat_order_payment.parent_id',array('method'));

in protected function _prepareCollection()

 $this->addColumn('method', array(
        'header' => Mage::helper('sales')->__('Payment Method'),
        'index' => 'method',
    ));

in protected function _prepareColumns()

with this getting blank column with heading Payment Method like in the image enter image description here

1 Answer 1

1

you can use like this to get payment method

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.