我在Magento中使用SOAP API构建android应用程序,它能够在移动设备上销售产品。我正在使用KSOAP2库文件。
但问题是我无法使用函数shoppingCartProductAdd
将产品添加到购物车。它给出错误产品的数据无效
所以,如果您有更好的方法将产品添加到购物车,请帮助我
答案 0 :(得分:0)
首先你必须得到会话ID,我希望你有会话ID 并首先创建购物车ID,下面是代码
//Creation of CART ID
SoapObject request = new SoapObject(MAGENTO_NAMESPACE, "shoppingCartCreate");
request.addProperty("sessionId", sessionId);
env.setOutputSoapObject(request);
androidHttpTransport.call("", env);
Object result = env.getResponse();
result = env.getResponse();
Log.d("cartId", result.toString());
以下是将产品添加到shoppig购物车的代码
SoapObject addprod = new SoapObject(MAGENTO_NAMESPACE, "shoppingCartProductEntity");
addprod.addProperty("product_id", 1059);
addprod.addProperty("sku", "ssbadracyonmat035");
addprod.addProperty("qty", 12);
SoapObject arrayOfProducts = new SoapObject(MAGENTO_NAMESPACE, "shoppingCartProductEntityArray");
arrayOfProducts.addProperty("products", addprod);
SoapObject cartProductAdd = new SoapObject(MAGENTO_NAMESPACE, "shoppingCartProductAdd ");
cartProductAdd.addProperty("sessionId", sessionId);
cartProductAdd.addProperty("quoteId", quoteId);
cartProductAdd.addProperty("products", arrayOfProducts);
cartProductAdd.addProperty("storeId", "4");
env.setOutputSoapObject(cartProductAdd);
androidHttpTransport.call("", env);
Log.e("BeforeCall", cartProductAdd.toString());
Object ResultForProductAddToCart = env.getResponse();
Log.d("productAddedToCart?", ResultForProductAddToCart.toString());