Magento 如何将订购的产品保存在数据库中?
发送订单后,Magento 如何保存订单产品(在 sales_flat_order_item 表中)。我需要这些文件,因为我也想将常规价格保存在数据库中;如果你有特价 Magento 仅在有人下订单时将特价保存在数据库中。 或者有人知道如何在数据库中保存每个订购产品的常规价格吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
慢慢地?小心?用SQL?我开玩笑,我开玩笑。
老实说,是的,您是正确的,订单项目表中存储的唯一数据是客户实际支付的价格(而不是正常价格)。如果要保存该表上的额外数据,请执行以下操作:
现在,您应该在数据库中拥有该数据,并且能够像任何其他列一样正常检索它。希望有帮助!
谢谢,
乔
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
我很好奇为什么你甚至需要将原始价格存储在表中...当你循环遍历订单的项目时,你总是可以动态查找它:
或者你可以编写自己的模块来创建'sales_flat_order_item' 中的新列,或创建您自己的表来引用该表中的特定 ID。您可以让您的模块观察订单成功事件,并循环遍历订单中的所有产品并在数据库中设置值。
就像约瑟夫在上面的评论中所说的那样,你永远不应该修改核心代码。如果您需要进行更改,请编写适当的模块来执行此操作。如果您正在修改核心代码(或者,在我看来,如果您正在创建此目录:app/code/local/Mage/),那么您就做错了。
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:
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.