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);

试试吧.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...