Lalit Kaushik
Lalit Kaushik

Reputation: 1062

add complete address in default columns in order grid

I want to add complete address in default "Bill to Name" and "Ship to Name" columns in order grid in Magento admin. I am attaching screen-shot for more explanation. enter image description here Please suggest me how can I achieve this?

Upvotes: 1

Views: 753

Answers (1)

Asif hhh
Asif hhh

Reputation: 1552

You can override the following class

 Mage_Adminhtml_Block_Sales_Order_Grid

now add the data by using renderer as you have access to order, get order id and load the shipping and billing addresses

   $order->getShippingAddress()
   $order->getBillingAddress()

Implement Renderer :

    class Mage_Adminhtml_Block_Sales_Order_Renderer_Billing extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
    {
 public function render(Varien_Object $row)
{

$order_id =  $row->getId();
    $order = Mage::getModel("sales/order")->load($order_id);
    $billing_address = $order->getBillingAddress();
return $billing_address;

}

}

In Grid file :

    $this->addColumn('billing_name', array(
        'header' => Mage::helper('sales')->__('Bill to Name'),
        'index' => 'billing_name',
        'renderer'  => 'Mage_Adminhtml_Block_Sales_Order_Renderer_Billing',
    ));

Upvotes: 1

Related Questions