2

So I wanted to change the columns in the sales - order - grid

I created my own version of the Grid.php (located at app\code\local\Mage\Adminhtml\Block\Sales\Order\Grid.php)

in _prepareCollection() I added

$collection->getSelect()->join(
    'sales_flat_order',
    'main_table.entity_id = sales_flat_order.order_id',
    array(Shipping_column)
);

(not correct shipping column - this just an example)

and also added the column to _prepareColumns()

Logged in to Magento admin and I have a new column - no problem

Then I wanted to add the tax from sales_flat_order

Again I added in _prepareCollection() and _prepareColumns()

$collection->getSelect()->join(
    'sales_flat_order',
    'main_table.entity_id = sales_flat_order.order_id',
    array(tax_column)
);

Logged into Magento admin and page went crashing - never loaded and ended in temporary error (502) - both backend and frontend. Had to call support to restart.

What did I do wrong?

1

The field order_id does not exist in sales_flat_order. You need use entity_id instead of order_id and columns is working, it should be shipping_amount instead Shipping_column and tax_amount field to join query

so change to

join(
    'sales_flat_order', 
    'main_table.entity_id = sales_flat_order.entity_id ',
    array(shipping_amount,tax_amount)
);
  • So instead of listing 2 new lines with $collection-> etc just put in 1 and here I can list all the new columns from SALES_ORDER_FLAT I need? – Aflaursen Apr 8 '15 at 10:15
  • just need one line – Amit Bera Apr 8 '15 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.