Magento - 以编程方式重新排序
我目前正在制作一个模块,要求我获取订单对象并使其自行重新排序。因此,在后端使用完全相同的商品和凭据创建一个新订单。
这是我迄今为止的代码......它似乎没有重新排序该项目或创建并添加另一个后端订单。
$personsOrder = Mage::getModel(’sales/order’);
$personsOrder->loadByIncrementId($order[’model_order_id’]);
$order_model = Mage::getSingleton(’adminhtml/sales_order_create’);
$personsOrder->setReordered(true);
$order_model->initFromOrder($personsOrder);
/*
$order_model->save();
$order_model->place();
$order_model->sendNewOrderEmail();
*/
非常感谢任何帮助!
I am currently making a module that requires me to take an order object and make it reorder itself.. thus, creating a new order in the backend with the exact same items and credentials.
This is the code that i have thus far… it doesn’t seem to reorder the item or create and add another backend order.
$personsOrder = Mage::getModel(’sales/order’);
$personsOrder->loadByIncrementId($order[’model_order_id’]);
$order_model = Mage::getSingleton(’adminhtml/sales_order_create’);
$personsOrder->setReordered(true);
$order_model->initFromOrder($personsOrder);
/*
$order_model->save();
$order_model->place();
$order_model->sendNewOrderEmail();
*/
Any help is greatly appreciated!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的第一个想法是您应该在第 2 行使用
$order->getIncrementId()
而不是$order['model_order_id']
,但我不确定您首先从哪里获取$order
。您是否检查过$order['model_order_id']
实际上返回了有效的增量 ID?我在任何地方都没有将 model_order_id 视为数据库中的字段...我建议您让 IDE 和 XDebug 正常工作,以便您可以在使用对象时检查对象并理解它们这是怎么回事。
干杯,
京东
My first thought is that you should be using
$order->getIncrementId()
on line 2 rather than$order['model_order_id']
, but I'm not sure where you're getting$order
from in the first place. Have you checked that$order['model_order_id']
is actually returning a valid increment ID? I don't seemodel_order_id
as a field in the database anywhere...I'd be suggesting that you getting your IDE and XDebug working so that you can inspect the objects as you work with them and understand what's going on.
Cheers,
JD
如果您第一次下的订单也是通过编码创建的,而不是从店面创建的,那么您需要确保已在
sales_flat_quote_item
表中添加一个条目。否则该订单无法重新订购。因此,请确保您创建的订单不是这种情况。If the order that you have placed the first time around is also created through coding and not from store front then you need to make sure that you have added an entry in the
sales_flat_quote_item
table. Otherwise that order cannot be reordered. So make sure it's not the case with your order creation.