Reputation: 831
After I send an order , how does Magento save the order products (in sales_flat_order_item table). I need the files, because I want to save the regular price in database also; if you have special price Magento only saves the special price in database when somebody make an order. Or does anyone have any idea how can I save the regular price in database for each ordered product?
Upvotes: 2
Views: 6482
Reputation: 2060
I'm curious why you even need to have the original price stored in the table... You could always look it up on the fly when you are looping through items of an order:
$origPrice = Mage::getModel('catalog/product')->load($item->getProductId())->getData('price');
Or you could write your own module that creates either the new column in 'sales_flat_order_item', or create your own table that references the particular id in that table. You could have your module observe the order success event, and loop through all the products in the order and set the value in the database.
Like Joseph said in a comment above, you should NEVER modify core code. If you need to make a change, write a proper module to do so. If you are modifying core code (or, in my opinion, if you are creating this directory: app/code/local/Mage/), then you are doing something wrong.
Upvotes: 0
Reputation: 27119
Slowly? Carefully? With SQL? I kid, I kid.
In all honesty, yes you are correct that the only data stored on the order item table is the price that the customer actually paid (as opposed to the regular price). If you want to save your extra data on that table, do the following:
Now, you should have that data in the DB and be able to retrieve it normally like any other column. Hope that helps!
Thanks, Joe
Upvotes: 4