ERROR On Create Invoiceexception' Mage_Core_Exception'有消息'无法创建空货。'在app / Mage.php:595

时间:2014-12-05 16:31:53

标签: php magento

当我使用此代码创建交易和发货时,我收到上述错误。不适用于捆绑产品。其他简单/可配置的产品使用相同的代码工作正常。

$shipment = $order->prepareShipment($qtysForProducts);
   $shipment->addTrack($track);
   $shipment->addComment($comment);
   $shipment->sendNewEmail(TRUE, $shipmentComment,$newSkuCustomer);
   $shipment->register();
   $shippmentId = $shipment->save()->getId();                       

$transactionSave = Mage::getModel('core/resource_transaction')
   ->addObject($shipment)
   ->addObject($shipment->getOrder())
   ->save();

提前致谢。

1 个答案:

答案 0 :(得分:2)

'无法创建空货。'装运未注册或没有物品时触发的消息。检查$ qtysForProducts数组并尝试下一个代码:

$shipment = $order->prepareShipment($qtysForProducts);
$shipment->addComment($comment);
if ($shipment) {
    $shipment->register();
    $shipment->getOrder()->setIsInProcess(true);
    try {
        $transactionSave = Mage::getModel('core/resource_transaction')
            ->addObject($shipment)
            ->addObject($shipment->getOrder())
            ->save();
    } catch (Mage_Core_Exception $e) {
        Mage::log($e->getMessage(), Zend_Log::ERR);
    }
}