i have to remove Bill to Name column & add two new columns product title name (which describe the product Name of Product) & Payment Method(which describe the payment method at the time of order in Magento admin panel (admin > sales > orders)
2 Answers
You can extend any grid in admin panel.
For order grid tutorials go to http://www.atwix.com/magento/customize-orders-grid/ and http://inchoo.net/magento/how-to-extend-magento-order-grid/
Go to app/code/core/Mage/Adminhtml/Block/Sales/Order/
open Grid.php file.
In the protected function _prepareColumns()
function you will see
$this->addColumn('billing_name', array(
'header' => Mage::helper('sales')->__('Bill to Name'),
'index' => 'billing_name',
));
you can either comment it or delete it. To add two new columns
$this->addColumn('name', array(
'header' => Mage::helper('sales')->__('Product Name'),
'index' => 'name',
));
$this->addColumn('method', array(
'header' => Mage::helper('sales')->__('Payment Method'),
'index' => 'method',
));
Now, you can see blank Product name
and Payment Method
fields. Replace following lines in protected function _prepareCollection()
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass())
->join(
'sales/order_item',
'`sales/order_item`.order_id=`main_table`.entity_id',
array(
'skus' => new Zend_Db_Expr('group_concat(`sales/order_item`.sku SEPARATOR ",")'),
'name' => new Zend_Db_Expr('group_concat(`sales/order_item`.name SEPARATOR ",")'),
)
)
->join(array('payment'=>'sales/order_payment'),'main_table.entity_id=parent_id','method');
$collection->getSelect()->group('main_table.entity_id');
$this->setCollection($collection);
return parent::_prepareCollection();
}
-
thanks, try this but not working showing error:- There has been an error processing your request Exception printing is disabled by default for security reasons. Error log record number: 1494638941 Magento is a trademark of Magento Inc. Copyright © 2014 Magento Inc.– DineshOct 30, 2014 at 7:55
-
you must have an order with multiple products. remove the line
$collection->getSelect()->join('sales_flat_order_item', 'main_table.entity_id = sales_flat_order_item.order_id',array('name'));
fromprotected function _prepareCollection()
.– HungryDBOct 30, 2014 at 7:58 -
@Dinesh Please update
/errors/local.xml
change action tag either<action>print</action>
or<action>email</action>
, then try again. You will get exact error, Post same here.– SandeshOct 30, 2014 at 10:33 -
i try this code $collection->getSelect()->join('sales_flat_order_item', '
sales_flat_order_item
.order_id=main_table
.entity_id', array('name' => new Zend_Db_Expr('group_concat(sales_flat_order_item
.name SEPARATOR ", ")'))); in protected function _prepareCollection() function to get products name this code in $this->addColumn('name', array( 'header' => Mage::helper('sales')->__('Product Name'), 'index' => 'name', )); in protected function _prepareColumns() but it to many product's names instead to only product related to order– DineshOct 30, 2014 at 12:07