5
votes

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.

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?

2

2 Answers

15
votes

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.

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.

6
votes

Another (better?) option is to follow Ivan's advice at Magento - Adding a new column to sales_flat_quote_item and sales_flat_order_item and use Magento's sales setup class to add your data onto the sales_flat_order table in an upgrade-safe manner.