Where is Magento order data stored? - magento

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!

Orders data are saved in database tables sales_flat_order and sales_flat_order_item
Discounts are applied in Mage_SalesRule_Model_Validator

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.

Related

From which table does magento extract the shipping and handling information in Order page on admin panel?

Previously I thought that the "price" shown in the order page under "Shipping and Handling Information" block in magento's admin panel is retrieved from "sales_flat_quote_shipping_rate" table but when I changed the value of price in the database manually it doesn't reflect any changes, from that i concluded that the price is not retrieved from that table.
Can anyone help me to understand this?
I have attached the screenshot to make clear what I am talking about.
Any help is appreciated.
Orders data are saved in database tables sales_flat_order and sales_flat_order_item
Check columns base_shipping_amount & shipping_amount in sales_flat_order table
To update the Shipping / Flat Rate, why are you modifying the DB, you can achieve this from the admin section.
Update the values their.
System -> Configuration -> Sales -> Shipping Methods -> Flat Rate.
In case you need to update it for a particular order then you can use tables suggested by Dushyant Joshi

How to change in the Magento DB the prices of the product

I've troubles to figure out how to change the prices of a product in the magento DB.
I tryed to change the prices in the catalog_product_index_price table but the price doesn't change.
There is a website here that explains it in more detail, but the short answer is that you need to change the price in the catalog_product_entity_decimal table and then reindex Product Prices in the backend (and potentially Product Flat Data as well)
Magento uses variety of indexing and caching methods that make simply changing the value directly in the database not a good idea.
If you look, you can see the prices are also defined in the Price Index tables:
catalog_product_index_price_idx
And also the flat tables (if you use them):
catalog_product_flat_1 (number 1 depends on store)
If you're trying to mass update prices, I recommend either using a tool such as Magmi or the built in Magento import methods to update prices. Directly modifying the database is generally not a good idea with Magento, given it's complex database structure.

Can Magento handle large numbers of product prices

I am using Magento 1.7.0.2, with approximately 4,000 product items and 3000 customer accounts, recently I have been tasks with uploading a large amount of customer prices. The prices will be held against the product as group prices, and the customers price will be determined by the group they belong to - all standard magento and all working fine.
However the requirement will mean i will be required to upload 650 customer groups, and then associate a product price with each group
This yeilds 650 * 4000 = 2,600,000 - A lot of prices!
I'm aware that this will take some time to complete as a process the question is can Magento handle this number of prices?
thanks
Magento is able to handle this. Of course it depends on the hardware also :).
There might be some problems in the add-to-cart and checkout process. by problems I mean it might slow down the process a little.
For product listing Magento uses the index tables for prices (and others) so this shouldn't be an issue.
By the way...your indexing process will take longer. You might not be able to run it from the backend (but that is not recommended anyway).

Magento Stock (Configurable, Bundle)

I have a website made with Magento, and a theme by me. The problem is:
The simple product with low stock is associated to a configurable product, and when i try to add a higher quantity of that simple product, it allows, and then, after the checkout proccess, we receive a e-mail from the store that there is a failure in the proccess like:
Payment operation failed:
Reason:
Not all products are available in the requested quantity
It occurs in bundle products that have a default quanity more than 1 too.
Someone can help me?
Thanks.
EDIT:
Found this solution but i can't truncate my sales tables on database. I have all my sales records there, and there are a lot of them. I can't loose it. Magento: After ordering configurable product, its canceled because its out of stock
How many orders do you need to remove? If you got a handful that you can count by hand, you can try this solution to remove unwanted orders.
how can i delete test order from magento
It looks like it should work, but, as always, review the code and try it on one order first..

Magento: Revert price data from index. False price data saved, but not indexed

i hope i am able to describe the problem correctly here, as it is quite complex. I guess you guys are my last chance.
We have ca. 120 config products based on 600 simple products. Some days ago, we accidently overwrote all the prices of the simple products with false prices. We did not notice as in the frontend every price is still ok, they are not indexed.
So we now have the correct prices in the frontend, but the wrong prices for the simple products in the backend.
Is there any method the get the prices from the indexed frontend and write them back in the backend?
Until i reindex all proces should be ok in the frontend.
Does anyone have any idea what i could do to get the prices right again?
If you browse the database, there should be a catalog_product_flat_1 table - this is basically your product index. You should have columns for all the product attributes (including SKU and Price) so you could export this table, then do a product export from Magento, then update all the prices/SKUs accordingly and re-import. Or duplicate the flat_1 table, then write a PHP script to loop through it, updating all the prices, then re-index your data (after checking it's worked of course!)

Resources