0

这是什么意思?

我试图以编程方式为订单创建发货,它抛出了一个错误,正如我在下面复制的那样。

我的代码:

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] =&gt; $orderId
[1] =&gt; 8
[2] =&gt; Royal mail Shipment
[3] =&gt; 1
[4] =&gt; 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-&gt;__call('create', Array)
#1 /home/toesocks/public_html/product_scanning/v2/functions/orderDispatch.php(82):     Mage_Sales_Model_Order_Shipment-&gt;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     />

有人可以解释一下这是什么意思,为什么我会收到这个错误?

亲切的问候
杰伊

4

1 回答 1

0

你得到一个 PHP 错误,不一定是 Magento 错误。 Mage_Sales_Model_Order_Shipment没有办法create()。你要的是不存在的东西。

查看Mage_Sales_Model_Order_Shipment_Api::create()以了解如何创建新货件。

另请参阅:在 magento 中,如何在订单中添加货件和跟踪编号

您使用 构建货件,Mage_Sales_Model_Order_Shipment::addItem()然后使用Mage_Sales_Model_Order_Shipment::save().

于 2013-03-28T00:27:37.460 回答