Magento - 以编程方式重新排序

发布于 2024-09-14 21:07:49 字数 520 浏览 5 评论 0原文

我目前正在制作一个模块,要求我获取订单对象并使其自行重新排序。因此,在后端使用完全相同的商品和凭据创建一个新订单。

这是我迄今为止的代码......它似乎没有重新排序该项目或创建并添加另一个后端订单。

$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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

指尖上得阳光 2024-09-21 21:07:49
$orderId= $YOUR_ORDER_NUMBER;
$personsOrder = Mage::getModel('sales/order')->load($orderId);
$order_model = Mage::getSingleton('adminhtml/sales_order_create');
$personsOrder->setReordered(true);
$order_model->initFromOrder($personsOrder);
$order_model->createOrder();
$orderId= $YOUR_ORDER_NUMBER;
$personsOrder = Mage::getModel('sales/order')->load($orderId);
$order_model = Mage::getSingleton('adminhtml/sales_order_create');
$personsOrder->setReordered(true);
$order_model->initFromOrder($personsOrder);
$order_model->createOrder();
败给现实 2024-09-21 21:07:49

我的第一个想法是您应该在第 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 see model_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

爱,才寂寞 2024-09-21 21:07:49

如果您第一次下的订单也是通过编码创建的,而不是从店面创建的,那么您需要确保已在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文