In my custom module, I have modified the checkout process a bit and added some custom fields in billing address section following the below tutorial:


Now, these custom fields here are saved in a different table in the form of a key=>value pair, based on order_id in sales_order_custom table created by my module itself.

Further, I want to get these values associated with the sales_order module and display some of these key=>value kind of fields in admin sales order grid.

How how do I join these two tables so that the keys also get converted into columns and I can retrieve them directly as "addColumn" index??

I tried following links, but I think they are somewhat not the right way I am approaching..

1) https://plugin.company/blog/join-eav-attribute-flat-table-collection-magento/ - trying this, I got this error : "Invalid entity_type specified: sales_order_custom"


Thanks in advance..

1 Answer 1


My article refers to joining an 'standard' Magento EAV attribute/table to a flat table in Magento.

What you are trying to do is join a custom table to a flat table.

Something like the following should do the trick:

$collection = Mage::getModel('sales/order')->getCollection();
              array('customattribute1' => 'sales_order_custom'),
              "customattribute.order_id=main_table.entity_id AND customattribute.key = 'keynumber1here'"

(replace keynumber1here with the key you'd like to add)

Then you could do the following in the grid:

     'label' => $this->__('Your Label'),
     'index' => 'customattribute1.value'

Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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