這是什麼意思?無效方法Mage_Sales_Model_Order_Shipment :: create
即時通訊嘗試以編程方式爲訂單創建貨件,因爲它在下面複製時拋出錯誤。
我的代碼:
if (!$order->canShip()) {
echo 'can not ship this order';
return false;
}
$itemQty = $order->getItemsCollection()->count();
$shipment = Mage::getModel('sales/service_order', $order)
->prepareShipment($itemQty);
$shipmentId = $shipment->create($order->getIncrementId(), $itemQty, 'Shipment created through ShipMailInvoice', true, true);
錯誤是:
<b>Fatal error</b>: Uncaught exception 'Varien_Exception' with message 'Invalid method Mage_Sales_Model_Order_Shipment::create(Array
(
[0] => $orderId
[1] => 8
[2] => Royal mail Shipment
[3] => 1
[4] => 1
)
)'
in /home/toesocks/public_html/lib/Varien/Object.php:569
Stack trace:
#0 /home/toesocks/public_html/product_scanning/v2/functions/orderDispatch.php(82): Varien_Object->__call('create', Array)
#1 /home/toesocks/public_html/product_scanning/v2/functions/orderDispatch.php(82): Mage_Sales_Model_Order_Shipment->create('15300007141', 8, 'Shipment create...', true, true)
#2 {main}
thrown in <b>/home/toesocks/public_html/lib/Varien/Object.php</b> on line <b>569</b><br />
可能有人請解釋一下我這是什麼意思,爲什麼我會收到這個錯誤?
親切的問候
JEY
Hi Rob,
if(!$ order-> canShip()){ echo'無法運送此訂單'; \t \t \t return false; } \t \t \t $ itemQty = $ order-> getItemsCollection() - > count(); $ shipment = Mage :: getModel('sales/service_order',$ order) - > prepareShipment($ itemQty); $ shipmentId = $ shipment-> create($ order-> getIncrementId(),$ itemQty,'ShipMailInvoice創建的貨件',true,true); – 2013-03-27 10:59:57
@Rob,你的意思是用該代碼編輯問題?如果是的話,我編輯了這個問題。 – 2013-03-27 11:12:27
很少有創建貨物的先決條件。你確定這些先決條件已經實現嗎? – oscprofessionals 2013-03-27 13:26:51