Categories


Archives


Recent Posts


Categories


The Orders Table

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

Magento Version: 1.5.0.1

More modern version of Magento have abandoned the EAV storage method for sales order information. Don’t worry, there’s still plenty of linked tables to trip you up!

One of the most common misunderstandings I’ve seen is that there’s two tables that store primary order information. The more commonly discovered table is sales_flat_order_grid. This is the table that’s used to display grid information in the Magento admin. However, it’s not the “true” place orders are stored.

That real central orders table is sales_flat_order. This is a little trickier than the other table relationships, because the primary key for sales_flat_order_grid is also a foreign key to sales_flat_order’s primary key. Because most MySQL tools don’t do a good job of advertising foreign key relationships via casual table browsing, I’ve seen a lot of people discover the entity_id key on sales_flat_order_grid and assume it’s the one true table.

Yet another reason you want to interact with Magento’s information via the Model layer unless you’re really sure you know what you’re doing.

Copyright © Alan Storm 1975 – 2019 All Rights Reserved

Originally Posted: 20th September 2011