Magento的SOAP API V2 shoppingCartProductAdd错误“的产品的一个项目没有标识或SKU" [英] Magento SOAP API v2 shoppingCartProductAdd error “One item of products do not have identifier or sku”

查看:86
本文介绍了Magento的SOAP API V2 shoppingCartProductAdd错误“的产品的一个项目没有标识或SKU"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试提交shoppingCartProductAdd API请求时收到一件商品没有标识符或sku"错误

I'm getting "One item of products do not have identifier or sku" error when attempting to submit shoppingCartProductAdd API request

我同时提交了有效的SKU和Product_ID.所以这个错误对我来说没有任何意义.

I'm submitting both a valid SKU and Product_ID. So the error doesn't make sense to me.

以下是一些相关代码……

Here's some of the relevant code…

Dim pendingCartItems As New List(Of shoppingCartProductEntity)
        If qtyAustin > 0 Then
            Dim ticketRequest As New shoppingCartProductEntity
            ticketRequest.sku = "RH_00001"
            ticketRequest.product_id = "2"
            ticketRequest.qty = qtyAustin
            pendingCartItems.Add(ticketRequest)
        End If

        AddToCart(pendingCartItems)


        Public Sub AddToCart(ByVal cartItems As List(Of shoppingCartProductEntity))
            mClient.shoppingCartProductAdd(mSession, mCart, cartItems.ToArray(), mStore)
        End Sub

shoppingCartProduct的API文档添加: http://www.magentocommerce .com/api/soap/checkout/cartProduct/cart_product.add.html

API documentation for shoppingCartProductAdd: http://www.magentocommerce.com/api/soap/checkout/cartProduct/cart_product.add.html

推荐答案

首先启用了 WS-I Magento中的合规性

Magento admin -> System -> Configuration -> Services -> Magento Core API

然后设置 " 到 ".

then set "WS-I Compliance" to "yes".

从主机获取符合WS-I要求的WSDL

Get the WSDL with WS-I compliance from your host

http://mymagentohost/index.php/api/v2_soap?wsdl=1

从以下位置配置SOAP/XML-RPC用户和角色

Configure the SOAP/XML-RPC users and roles from

Magento admin -> System -> Web Services -> SOAP/XML-RPC-Users & SOAP/XML-RPC-Roles

和设置权限.

现在您可以生成客户端代理类(Axis,Axis2,Microsoft WSDL工具...等)

Now you can generate your client Proxy classes (Axis, Axis2, Microsoft WSDL tool... etc)

检查您的端点URL,应该是

Check your endpoint URL, it should be

http://mymagentohost/index.php/api/v2_soap/index/

我使用Axis2进行的功能测试代码

My functional testing code using Axis2

package magento;

import java.rmi.RemoteException;

import magento.MagentoServiceStub.EndSessionParam;
import magento.MagentoServiceStub.LoginParam;
import magento.MagentoServiceStub.LoginResponseParam;
import magento.MagentoServiceStub.ShoppingCartCreateRequestParam;
import magento.MagentoServiceStub.ShoppingCartCreateResponseParam;
import magento.MagentoServiceStub.ShoppingCartProductAddRequestParam;
import magento.MagentoServiceStub.ShoppingCartProductAddResponseParam;
import magento.MagentoServiceStub.ShoppingCartProductEntity;
import magento.MagentoServiceStub.ShoppingCartProductEntityArray;

import org.apache.axis2.AxisFault;

public class Test {

    public static void main(String[] args) {
        try {
            MagentoServiceStub stub = new MagentoServiceStub();

            LoginParam loginParam = new LoginParam();
            loginParam.setUsername("myuser");
            loginParam.setApiKey("1b6bf41e547e06b5b795d44b2f8f8f54");
            LoginResponseParam p = stub.login(loginParam);
            String sessionId = p.getResult();

            ShoppingCartCreateRequestParam createParam = new ShoppingCartCreateRequestParam();
            createParam.setSessionId(sessionId);
            //param2.setStore("1");
            ShoppingCartCreateResponseParam resp = stub.shoppingCartCreate(createParam);
            int sr = resp.getResult();

            ShoppingCartProductAddRequestParam prodcutAddParam = new ShoppingCartProductAddRequestParam();
            prodcutAddParam.setSessionId(sessionId);
            prodcutAddParam.setQuoteId(sr);
            ShoppingCartProductEntityArray array = new ShoppingCartProductEntityArray(); 
            ShoppingCartProductEntity producto = new ShoppingCartProductEntity();
            producto.setSku("prueba");
            producto.setQty(1);
            array.addComplexObjectArray(producto);
            prodcutAddParam.setProductsData(array);

            ShoppingCartProductAddResponseParam prodAddResult = stub.shoppingCartProductAdd(prodcutAddParam);
            System.out.println("product added? " + prodAddResult.getResult());

            EndSessionParam endSessionParam = new EndSessionParam();
            endSessionParam.setSessionId(sessionId);

            stub.endSession(endSessionParam);

        } catch (AxisFault e) {
            e.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        }

    }

}

希望这对您有所帮助.

这篇关于Magento的SOAP API V2 shoppingCartProductAdd错误“的产品的一个项目没有标识或SKU"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆