cancel
Showing results for 
Search instead for 
Did you mean: 

Split shipping address in grid orders

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Split shipping address in grid orders

In file app / code / local / Mage / Adminhtml / Block / Sales / Order / Grid.php (copy of the original Grid.php) I have added the following code in protected function _prepareCollection ()

$ Table1 = Mage :: getSingleton ('core / resource')
-> getTableName ('sales_flat_order_address');
$ Shipping = "(select max (t.street) from` $ table1` as t where t.parent_id = main_table.entity_id AND address_type = 'shipping') ";
$ Collection-> getSelect () -> from ('', '$ shipping as shipping_city');

This serves to pick up the shipping address to add the following code as a column in the grid afterwards

$ This-> addColumn ('shipping_city', array (
'Header' => Mage :: helper ('sales') -> __ ('Shipping address'),
'Index' => 'shipping_city',
'Filter_index' => 'shipping.city'
));


The problem is now that the full address is included here. So also the 2nd and 3rd address line that customers can enter.
Magento adds these address lines into 1 field in the database

How can I get these different address lines to display in a different column in the grid?
I've read that the different lines in the database are divided by / n, but how can I check this and show the correct address fields in the columns?

thank you in advance
Tom