微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – Magento我如何以编程方式发送订单?

我正在寻找一些代码来在Magento中添加MassAction并从sales_order / index发货并完成多个订单

不知何故订单没有发货.

看起来(一个完全正常的顺序)没有通过canship()测试.它应该传递$orderid的订单吗?

这是我的代码

//Get orderids
$orderIds = $this->getRequest()->getPost('order_ids');

//verify if the array is not empty
if (!empty($orderIds)) {
//loop through orders
foreach ($orderIds as $orderId) {

// Dont kNow what this does
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);

// Is the order shipable?
if($order->canShip())
{
$itemQty =  $order->getItemsCollection()->count();
// This first deFinition and 2nd look overlapping,our one is obsolete?
$shipment = Mage::getModel('sales/service_order',$order)->prepareShipment($itemQty);
$shipment = new Mage_Sales_Model_Order_Shipment_Api();

// But still,no shipment,why?
$shipmentId = $shipment->create($orderId,array(),'Shipment created through ShipMailInvoice',true,true);
您需要按ID加载,如果获得orderID,或者通过IncrementOrderId加载,则实际获得Order incrementId.

用这个:

$order = Mage::getModel(‘sales/order’)->load($orderId);

让我们知道它是否有效.

然后 :

$shipmentId = $shipment->create($order->getIncrementId(),$itemQty,true);

试试吧.

原文地址:https://www.jb51.cc/php/134531.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐