美好的一天,在这种情况下需要帮助 . 我们有一个客户端,它有一个Magento ver 1.9系统,我没有't have access. They have asked us to create a mobile app and we are using as PHP Laravel 5.1 as a proxy rest api to call Magento'的SOAP API V2 . 其中一项服务是将产品添加到购物车 . 我已经使用了这个引用http://www.magentocommerce.com/api/soap/checkout/cartProduct/cart_product.add.html但不幸的是,当我调用该服务时,我收到了这个错误
"One item of products do not have identifier or sku"
这是php代码的片段:
$data = array_add($data, 'product_id', $request->json('product_id'));
$data = array_add($data, 'sku', $request->json('sku'));
$data = array_add($data, 'qty', $request->json('qty'));
$data = array_add($data, 'options', $request->json('options'));
$data = array_add($data, 'bundleOption', $request->json('bundleOption'));
$data = array_add($data, 'bundleOptionQty', $request->json('bundleOptionQty'));
$data = array_add($data, 'links', $request->json('links'));
try {
$result = $client->shoppingCartProductAdd($sessionId,$cartId,$data);
if ($result) {
return $this->respond([
'message' => 'Product Successfully added to Cart.'
]);
}
} catch (SoapFault $e) {
$message = $e->getMessage();
return $this->respondInternalError($message);
}
这是Json请求
{"product_id":"13","sku":"Warm-Welcome-Coat","qty":"5","options":"","bundleOption":"","bundleOptionQty":"","links":""}
我'm sure that the product is existing as I used the api to call the product list. I'已经尝试过这个解决方案 - > Magento SOAP API v2 shoppingCartProductAdd error “One item of products do not have identifier or sku”但它对我不起作用 .
1 回答
我刚刚解决了这个问题 . 似乎我的数据数组的格式不正确,因为Magento的样本声明:
虽然我的示例中的$ data只是一个数组 .