我在看一些代碼,在Magento和船舶和完整的多個訂單增加MassAction
從sales_order/index
Magento如何以編程方式發送訂單?
莫名其妙的命令沒有被運。
它看起來像(完全正常的順序)沒有通過canship()
測試。是否應通過$orderid
傳遞$order
?
這裏是我的代碼
//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);
非常感謝@ShaunOReilly。它通過canship()... 但出現下一個錯誤:order_not_exists 'code' 跟蹤:訂單/出貨/ Api.php(142):Mage_Api_Model_Resource_Abstract - > _故障( 'order_not_exist ......') 銷售/ OrderController.php(45):Mage_Sales_Model_Order_Shipment_Api->創建( '121',陣列, '出貨創造... ...',真,真) 'code' – 2012-01-30 19:50:31
所以現在它崩潰上$ shipment->創建。我嘗試了$ order和orderId。兩者都不起作用。 $ order導致訪問衝突 $ shipmentId = $ shipment-> create($ order,array(), – 2012-01-30 19:57:44
看看我的答案的最後編輯。 – ShaunOReilly 2012-01-30 23:52:49