dongnunai3125 2015-11-28 05:44
浏览 37
已采纳

Magento SOAP API和PHP:一项产品没有标识符或sku

Good Day, need help on this scenario. We have a client who has a Magento ver 1.9 system which I don'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's SOAP API V2. One of the services was to add a product to the cart. I've used this reference http://www.magentocommerce.com/api/soap/checkout/cartProduct/cart_product.add.html but unfortunately when I call the service I'm getting this error

"One item of products do not have identifier or sku"

Here is the snippet of the php code:

$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);
}

Here is the Json request

{"product_id":"13","sku":"Warm-Welcome-Coat","qty":"5","options":"","bundleOption":"","bundleOptionQty":"","links":""}

I'm sure that the product is existing as I used the api to call the product list. I've tried this solution -> Magento SOAP API v2 shoppingCartProductAdd error “One item of products do not have identifier or sku” but it is not working for me.

  • 写回答

1条回答 默认 最新

  • dqpciw9742 2015-11-28 06:16
    关注

    I just solved in this problem. It seems that the format of my data array is incorrect as the sample from the Magento states that:

    $result = $proxy->shoppingCartProductAdd($sessionId, 10, array(array(
    'product_id' => '4',
    'sku' => 'simple_product',
    'qty' => '5',
    'options' => null,
    'bundle_option' => null,
    'bundle_option_qty' => null,
    'links' => null
    )));
    

    While the $data from my example is just an array.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?