Hi
I search everywhere to show the street address in customer grid in admin end But no found any solution for this.
Finally I review the code and make a new way to do this .
1. copy file Grid.php form ...app\code\core\Mage\Adminhtml\Block\Customer\Grid.php to .....app\code\local\Mage\Adminhtml\Block\Customer\Grid.php
2. open the customer 's Grid.php in ....app\code\local\Mage\Adminhtml\Block\Customer\Grid.php
and add the follwing code in _prepareColumns() function
\\\\\\\\\\\\\\\\\\\\\
$this->addColumn('street1', array(
'header' => Mage::helper('customer')->__('Street 1'),
'index' => 'entity_id',
'renderer'=> new Mage_Adminhtml_Block_Customer_Renderer_Street1()
));
$this->addColumn('street2', array(
'header' => Mage::helper('customer')->__('Street 2'),
'index' => 'entity_id',
'renderer'=> new Mage_Adminhtml_Block_Customer_Renderer_Street2()
));
\\\\\\\\\\\\\\\\\\\\\\\
2. make a directory in ....app\code\local\Mage\Adminhtml\Block\Customer\ named Renderer
and create two files in ....app\code\local\Mage\Adminhtml\Block\Customer\Renderer\
Street1.php
for code
\\\\\\\\\\\\\\\\
class Mage_Adminhtml_Block_Customer_Renderer_Street1 extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
public function render(Varien_Object $row)
{
$value = $row->getData($this->getColumn()->getIndex());
$customer = Mage::getModel('customer/customer')
->load($value); //put customer id here
$data = array();
foreach ($customer->getAddresses() as $address)
{
$data = $address->getStreet(1);
}
if(empty($data))
{
return '';
}else{
return $data;
}
}
}
\\\\\\\\\\\\\\\\\
and second one is Street2.php
\\\\\\\\\\\\\\\\\\\\\\\\\\\\
class Mage_Adminhtml_Block_Customer_Renderer_Street2 extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
public function render(Varien_Object $row)
{
$value = $row->getData($this->getColumn()->getIndex());
$customer = Mage::getModel('customer/customer')
->load($value); //put customer id here
$data = array();
foreach ($customer->getAddresses() as $address)
{
$data = $address->getStreet(2);
//var_dump($data);
}
if(empty($data))
{
return '';
}else{
return $data;
}
}
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
and that all done.
Enjoy!!