Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is Magento order data stored?

I am running Magento 1.6.2 and have an intermittent error cropping up with some sales orders. The customer is being charged correctly, but the Magento admin page when viewing the sale reports incorrect values. I understand why it is doing it incorrectly - I have a 10% discount off a full section of products on my website, and it is because of this that something is going wrong.

Again, the customer is paying the correct (discounted) amount, but the data must be being stored incorrectly in the magento database because looking at it in the admin system doesn't total the values correctly. The Catalog Price Rule that applies the 10% discount is not accounted for in the displayed totals.

To add to my woes, we use Zynk to bring data in from Magento to our Sage 200 backoffice system, and the data getting imported into that system is also missing the 10% discount, making reconciliation of order payments and Sage invoices a complete pain.

The only thing I can think is that somewhere somehow the data is being stored in the magento database incorrectly (not having had the 10% discount applied to it) so when Zynk collects the data, it is incorrect.

Can anyone help me understand where I can find the order data in the Magento database so I can see what was stored for a specific Magento order number - I can at least begin to debug this then, maybe?

If someone has details of where to find the code used by Magento to perform the order database transactions, specifically where the discounts should be applied before storing the data, that would be a big help too.

Cheers!

like image 849
robgt Avatar asked Nov 12 '12 12:11

robgt


2 Answers

Orders data are saved in database tables sales_flat_order and sales_flat_order_item

Discounts are applied in Mage_SalesRule_Model_Validator

like image 55
Piotr Avatar answered Sep 18 '22 13:09

Piotr


You can find orders and order items data in your (tables prefix)_sales_flat_order and (tables prefix)_sales_flat_order_item respectively. but remember that when an order is placed Magento simply copies the data from its respective quote. so in my opinion you should be checking (table prefix)_sales_flat_quote and (table prefix)_sales_flat_quote_item first.

like image 35
Ehsan2e Avatar answered Sep 21 '22 13:09

Ehsan2e