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.

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

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?