You need to extend the order grid (assuming that it is already familiar to you).
in the extended php file app/code/local/Yournamespace/Yourmodule/Block/Adminhtml/.../Grid.php
class Yournamespace_Yourmodule_Block_..._Grid extends Mage_Adminhtml_Block_Sales_Order_Grid{
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass())
->join(array('soa' => 'sales/order_address'), 'soa.parent_id=main_table.entity_id and soa.address_type = "billing"', array('full_address'=>'CONCAT(soa.firstname, " " , soa.lastname, ",<br/>", soa.street, ",<br/>", soa.city, ",<br/>", soa.region, ",<br/>", soa.postcode)' ), null,'left')
->join(array('soas' => 'sales/order_address'), 'soas.parent_id=main_table.entity_id and soas.address_type = "shipping"', array('full_address_ship'=>'CONCAT(soas.firstname, " " , soas.lastname, ",<br/>", soas.street, ",<br/>", soas.city, ",<br/>", soas.region, ",<br/>", soas.postcode)' ), null,'left');
$this->setCollection($collection);
return parent::_prepareCollection();
}
...
then inside protected function _prepareColumns()
method replace the following code
$this->addColumn('billing_name', array(
'header' => Mage::helper('sales')->__('Bill to Name'),
'index' => 'billing_name',
));
$this->addColumn('shipping_name', array(
'header' => Mage::helper('sales')->__('Ship to Name'),
'index' => 'shipping_name',
));
with
$this->addColumn('full_address', array(
'header'=> Mage::helper('sales')->__('Billing Address'),
'width' => '80px',
'type' => 'text',
'index' => 'full_address',
));
$this->addColumn('full_address_ship', array(
'header'=> Mage::helper('sales')->__('Shipping Address'),
'width' => '80px',
'type' => 'text',
'index' => 'full_address_ship',
));
You're done!
The other easy and recommended way would be using event and observer:
in your module config.xml
under config tag...
<config>
...
<adminhtml>
...
<events>
<sales_order_grid_collection_load_before>
<observers>
<vendor>
<type>singleton</type>
<class>yourmodule/adminhtml_observer</class>
<method>filterOrderCollection</method>
</vendor>
</observers>
</sales_order_grid_collection_load_before>
<core_block_abstract_prepare_layout_after>
<observers>
<vendor>
<type>singleton</type>
<class>yourmodule/adminhtml_observer</class>
<method>saleOrderLayout</method>
</vendor>
</observers>
</core_block_abstract_prepare_layout_after>
in app/code/local/Yournamespace/Yourmodule/Model/Adminhtml/Observer.php
<?php
class Yournamespace_Yourmodule_Model_Adminhtml_Observer{
public function filterOrderCollection($observer){
$collection = $observer->getEvent()->getOrderGridCollection();
$collection->join(array('soa' => 'sales/order_address'), 'soa.parent_id=main_table.entity_id and soa.address_type = "billing"', array('full_address'=>'CONCAT(soa.firstname, " " , soa.lastname, ",<br/>", soa.street, ",<br/>", soa.city, ",<br/>", soa.region, ",<br/>", soa.postcode)' ), null,'left');
$collection->join(array('soas' => 'sales/order_address'), 'soas.parent_id=main_table.entity_id and soas.address_type = "shipping"', array('full_address_ship'=>'CONCAT(soas.firstname, " " , soas.lastname, ",<br/>", soas.street, ",<br/>", soas.city, ",<br/>", soas.region, ",<br/>", soas.postcode)' ), null,'left');
}
public function saleOrderLayout($evt){
$tabBlock = $evt->getBlock();
if($tabBlock instanceof Mage_Adminhtml_Block_Sales_Order_Grid){
$tabBlock->addColumnAfter('full_address', array(
'header'=> Mage::helper('sales')->__('Billing Address'),
'width' => '80px',
'type' => 'text',
'index' => 'full_address',
), 'created_at');
$tabBlock->addColumnAfter('full_address_ship', array(
'header'=> Mage::helper('sales')->__('Shipping Address'),
'width' => '80px',
'type' => 'text',
'index' => 'full_address_ship',
), 'full_address');
}
}
}
Best Answer
Add in your module:
sales_order_grid.xml view/adminhtml/ui_component/
Now add, BillTo.php in Ui/Component/Listing/Column/BillTo.php