Magento自定义订单属性/字段?射中自己的脚? [英] Magento custom order attribute/fields? Shooting myself in the foot?

查看:68
本文介绍了Magento自定义订单属性/字段?射中自己的脚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个涵盖4个域的单一目录来构建Magento商店:美国1个,欧洲3个(英国,法国和德国).在欧洲有1个配送仓库,在美国有1个配送仓库,在美国有一种非正式/内部的仓库",可以满足赠品等需求,我们并未追踪Magento的库存水平.我们需要跟踪特定的交易类型(例如普通网络销售)以及内部/管理员订单(例如非网络销售,赠品,贸易展览订单等).我的计划是扩展核心订单模型并添加某种订单/交易类型"字段,然后在下订单时处理订单数据,并根据商店ID和订单类型"值直接将其发送到哪个仓库进行履行.

I'm building a Magento store using a single catalog over 4 domains: 1 for the US and 3 for Europe (UK, French, and German). There's 1 fulfillment warehouse in Europe, 1 in the US and a sort of unofficial/internal "warehouse" in the US where giveaways and such are fulfilled, and we are not tracking inventory levels in Magento. We need to track particular transaction types like plain web sales along with internal/admin orders like non web sales, giveaways, trade show orders, etc. My plan is to extend the core order model and adding some kind of "order/transaction type" field and then, upon the placement of an order, process the order data and direct which warehouse it is sent off to for fulfillment based on the store id and the 'order type' value.

作为Magento的新手,我想知道由于某种原因这种设置是否是个坏主意.我会在脚上开枪吗?有任何原因可能导致单个目录有问题吗?有没有更简单或更好的方式来处理此流程?有没有办法像向产品一样向订单添加自定义属性?

Being new to Magento, I want to know if this kind of setup is a bad idea for any reason. Am I shooting myself in the foot? Is there any reason a single catalog might be problematic? Is there an easier or better way of handling this flow? Is there a way to add custom attributes to orders like you can to products?

推荐答案

您正在朝正确的方向前进,但是(与大多数Magento一样),有两种选择.这里最重要的原则是,修改的体系结构一定不能导致破坏核心上的升级/补丁的情况.有趣的是,Magento已从当前版本的Mage_Sales_Model_Order(及相关对象)的高度可扩展且升级安全的(主要是)EAV模型中移出.这使得以升级安全的方式(恕我直言)添加属性更加困难.

You're heading in the right direction, but (as with most things Magento), there are a couple of options. The most important principle here is that the architecture of the modifications must not lead to the situation where upgrades/patches on the core are compromised. What's interesting about that is that Magento has moved away from the highly extensible and upgrade-safe (mostly) EAV model for Mage_Sales_Model_Order (and related objects) in the current release. That makes it more difficult to add attributes in a upgrade-safe manner, IMHO.

我建议您使用Observer系统将新的属性值添加到相关的Model中.也就是说,不要将属性添加到Order模型本身中,而是创建一个包含order_id和您的自定义属性的模型.挂钩适当的事件(对于所有订单,可能为sales_convert_quote_to_order;对于前端订单,可能为checkout_type_onepage_save_order_after),然后检查报价项目以在自定义模型中设置值.在执行将订单传输到履行机构的过程时,可以通过order_id查找自定义属性.

I would recommend that you use the Observer system to add your new attribute values, but into a related Model. That is, rather than adding the attribute into the Order model itself, create a model that holds an order_id and your custom attributes. Hook into the appropriate event (probably sales_convert_quote_to_order for all Orders or checkout_type_onepage_save_order_after for frontend orders) and examine the Quote Items to set the values in your custom Model. When you execute your process to transmit orders to the fulfilment house, you can lookup the custom attributes via the order_id.

这篇关于Magento自定义订单属性/字段?射中自己的脚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆