在 Magento 中保存订单的额外数据
我必须向订单页面添加一列,这意味着向 sales_flat_order_grid
添加一列。这两种方法都是可能的,但是我不知道如何添加值以便将其保存在我的新列中。
我也必须注册一个新属性吗?
该值不存在于报价中,因此我想我不需要在 config/global/fieldsets/sales_convert_quote 下注册,因为该值不在那里进行转换。
使用 Magento 企业版 1.8。
I have to add a column to the orders page which means adding a column to sales_flat_order_grid
. Both of those are possible however I don't know how to add a value so that it gets saved in my new column.
Do I have to register a new attribute too?
The value is not present in the quote so I guess I don't need to register under config/global/fieldsets/sales_convert_quote
since the value isn't there to be converted.
Using Magento Enterprise 1.8.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
经过大量的尝试和错误 - 很多错误 - 我想我现在已经成功了。
首先,在
Mage_Sales_Model_Mysql4_Order_Abstract::updateGridRecords()
中更新sales_flat_order_grid
,按照我计算出的轨迹,它会检查“主”表 (sales_flat_order< /code>)和主表+“_grid”(
sales_flat_order_grid
),获取它们列的交集并从中构造一个查询。因此,网格表中所需的任何列也必须位于主表中。它不是 EAV 样式的实体,因此不需要创建属性。这是我的设置脚本:
接下来,我需要额外的列来显示在管理中的所有订单表中。为此,我覆盖了每个相关的块。
在 My/Module/Block/Adminhtml/Sales/Order/Grid.php 中,我做了以下操作:
同样,在 My/Module/Block/Adminhtml/Customer/Edit/Tab/Orders 中。 php 和
My/Module/Block/Adminhtml/Customer/Edit/Tab/View/Orders.php
我添加了此功能:最后,在事件
sales_convert_quote_to_order 中完成
我填充了新字段。该位并不那么重要,只要您在保存订单之前的某个时间点添加数据即可。After a lot of trial and error - a lot of error - I think I have it now.
To begin with the
sales_flat_order_grid
is updated inMage_Sales_Model_Mysql4_Order_Abstract::updateGridRecords()
, by following the trail I worked out it inspects both the "main" table (sales_flat_order
) and the main table + "_grid" (sales_flat_order_grid
), takes the intersect of their columns and constructs a query from that. So any column you need in the grid table must also be in the main table. It's not an EAV-style entity so attributes don't need to be created.Here is my setup script:
Next, I needed the extra column to show in all order tables in admin. To do this I overrode each relevant block.
In
My/Module/Block/Adminhtml/Sales/Order/Grid.php
I made the following:Similarly, in
My/Module/Block/Adminhtml/Customer/Edit/Tab/Orders.php
andMy/Module/Block/Adminhtml/Customer/Edit/Tab/View/Orders.php
I added this function:Finally, to finish off, in the event
sales_convert_quote_to_order
I populated the new field. This bit isn't as important, so long as you add the data at a point before the order is saved.您必须添加属性,最好的方法是通过扩展更新或设置脚本。由于订单和报价基于平面表结构,这实际上意味着向这些表添加更多字段
还请参阅 在 Magento 设置脚本中更改表而不使用 SQL
you have to add attributes , best way to do so is via your extensions update or setup script. As the order and quote are based on flat table structures it really means adding more fields to those tables
also see ALTER TABLE in Magento setup script without using SQL
另外,您可以使用它来将新的“属性”(at 实际上是一列,因为是扁平的)添加到 sales_flat 和 sales_flat_ _grid
您的安装程序必须是:Mage_Sales_Model_Entity_Setup 以使用网格键。
请记住,如果您要将 sales_flat_order 中的现有列添加到 sales_flat_order_grid,则需要重新同步 sales_flat_order_grid 表:
在 Magento 中,如何使用 sales_flat_order 中的数据填充 sales_order_grid 中的新列?
Also, you can use this for adding the new "attribute" (at really is a column because is flat) to both, the sales_flat and the sales_flat_ _grid
your installer must be: Mage_Sales_Model_Entity_Setup for using the grid key.
And remember if you are adding an existent columnd from sales_flat_order to sales_flat_order_grid, then you need to resync the sales_flat_order_grid table:
In Magento, how do I populate a new column in sales_order_grid with data from sales_flat_order?