转自:inchoo.net - magento add order (create order , 增加订单)
2014-02-21 10:05
337 查看
Programmatically create order in Magento
24th OCT 2010 | Posted by Branko Ajzelein
Magento,
Orders,
Programming
Surprisingly one of the trickiest parts of “under the hood” Magento is how to create order programmatically. At least for me, this was/is the most complex area of Magento development. Reason why it is so difficult is that the order creation process is all
but not straightforward. You cannot simply instantiate order model, set some data and call upon the save() method. If you ask me, this is how it should be done.
So why cannot we apply approach like generic one show below?
anything, from getting shipping calculations from shipping gateways to handling credit card processing from payment gateways. On one hand it’s a simple, yet extremely complex process to trace and try to simulate into straight forward order creation by your
custom code. Little less complex is the admin order creation, or at least it looks like less complex.
Basically if you as an admin try to create an order from Magento, you have these certain steps where you first choose the customer for which you wish to create order, then you choose store, then you choose product, shipping method, payment method, etc. Each
of this steps actually manipulates current session values as we are talking about AJAX-ed behavior. So basically Magento models internally use session reading for setting the necessary values in place of having the direct methods by which you yourself can
set those values like customer id, store id, etc.
With enough time on your side, strong will and determination one can monitor, analyze and trace the process of such order creation in order to try to execute it with it’s own custom code.
Below you will find an example of code that does exactly that, it programmatically creates order in Magento.
There are far more complex combinations you might need. Hope this code serves you as a good starting point.
Cheers.
相关文章推荐
- Magento 订单后台增加支付接口来源列
- magento 订单order 增加栏目
- magento修改订单支付状态,增加订单支付选项
- Magento后台订单页面增加邮箱项
- Magento入门基础 - 在magento后台增加一个自定义订单状态
- 如何在magento后台增加一个自定义订单状态
- Magento后台订单列表页,增加SKU、Qty、客户邮箱字段
- 学习ASP.NET Core Razor 编程系列十二——在页面中增加校验
- asp.net服务器组件开发给System.Web.UI.WebControls.Label增加单击事件
- magento修改发送邮件内容和订单邮件提醒设置
- magento修改发送邮件内容和订单邮件提醒设置
- 表格(增加行号) http://www.blogjava.net/zeyuphoenix/archive/2010/04/19/318788.html
- 1.TreeView.应用--2.asp.net 2.0中TREEVIEW中动态增加结点--3.msdn中nasp.net 2.0中TREEVIEW中动态增加结点--4.TreeView.ImageSet 属性,换换treeview的皮肤收藏
- ASP.NET中数据库的操作初步----增加、删除、修改
- C#.NET通用权限管理系统组件中数据集权限设置功能增加内部组织机构选项功能
- asp.net gridview中增加单击单元格事件
- Magento侧边栏增加新闻区块---Holiday模板
- 浅析Microsoft .net PetShop程序中的购物车和订单处理模块(Profile技术,异步MSMQ消息)
- 给ASP.Net表单增加验证码
- Magento联表查询产品的Group Price 以及 历史已完成订单的产品的price 的 SQL 语句