我在看一些代码,在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