0
我在具有2行Magento的1.x的订单。其中一种是简单的产品,另一种是可配置的产品。两种产品的order_qty
是2
。创建通过SOAP API V2在Magento的具体项目与配置的产品的订单出货 - 无法创建一个空的货物错误
我试图创建可配置产品之一的装运的1
这里的量是我requestBody
(JSON对象),其定义特定的货物我想创建:
{
"orderIncrementId":"100006762",
"items":[
{
"sku":"ABCD1234",
"qty":1
}
]
}
这里是展示出货创造我实现的一部分:如文档中列出这里
// Parse shipment sku => qty hash map
$shipmentQtys = [];
foreach ($requestBody['items'] as $shipmentItem)
$shipmentQtys[$shipmentItem['sku']] = (int)$shipmentItem['qty'];
// Load sales order info
$orderInfo = $this->getOrder($requestBody['orderIncrementId']);
// Build itemsQty from shipment
$itemsQty = [];
foreach ($orderInfo->items as $orderItem) {
if ($orderItem->product_type != 'simple') {
continue;
}
$itemSku = $orderItem->sku;
$itemId = $orderItem->item_id;
if (array_key_exists($itemSku, $shipmentQtys)) {
$itemsQty[] = [
'order_item_id' => $itemId,
'qty' => $shipmentQtys[$itemSku]
];
}
}
// Create shipment
$comments = '';
$email = false;
$includeComment = false;
$shipmentIncrementId = $this->apiClient->salesOrderShipmentCreate(
$this->sessionId,
$orderIncrementId,
$itemsQty,
$comments,
$email,
$includeComment);
// Debug
var_dump($shipmentIncrementId);
我使用SOAP API的V2, :http://devdocs.magento.com/guides/m1x/api/soap/sales/salesOrderShipment/sales_order_shipment.create.html
当我的代码运行时,我得到以下错误:
Cannot create an empty shipment.
所以我甩我$itemQty
,以确保我已经分析的匹配SKU为一个简单的产品,它有正确的数据:
Array
(
[0] => Array
(
[order_item_id] => 9657
[qty] => 1
)
)
任何想法可能是错误的?
我尝试这样做,仍然没有工作。我认为问题与为可配置产品创建货件有关。 – Latheesan
我们不能在magento中进行可配置产品的装运,而不是仅对配置子产品进行装运。 –
我知道这一点。如果你看看我的代码,当我遍历订单项时,我只加载'item_id',其中'product_type' ='simple'。 – Latheesan