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

前端之家收集整理的这篇文章主要介绍了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.f2er.com/php/134531.html

猜你在找的PHP相关文章