【问题标题】:Magento: transfer product to customer's cart androidMagento:将产品转移到客户的购物车 android
【发布时间】:2014-08-22 05:26:21
【问题描述】:

我正在使用 android ksoap2 和 magento soap api V2 制作购物车。我无法使用 api shoppingCartProductMoveToCustomerQuote 将购物车产品移动到客户的购物车。我收到错误,因为“客户报价不存在”。我使用了link

我已经使用了下面的代码:

    private String response,id;
      String[][] Products = new String[][] {{"20","20","1"}};
        protected String doInBackground(String... params)
           {
            try
            {
              //SoapEnvelop.VER11 is SOAP Version 1.1 constant
              SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);  
              envelope.dotNet = true;
              envelope.xsd = SoapSerializationEnvelope.XSD;
              envelope.enc = SoapSerializationEnvelope.ENC;
              SoapObject request = new SoapObject(NAMESPACE,"login");
              request.addProperty("username", "***");
              request.addProperty("apiKey", "*********");

              //envelope.bodyOut = request;
              envelope.setOutputSoapObject(request);
              HttpTransportSE transport = new HttpTransportSE(URL);
              try 
              {
                 transport.debug=true;
                 transport.call(NAMESPACE + SOAP_ACTION_PREFIX + "shoppingCartProductAdd", envelope);
//                transport.call(NAMESPACE + SOAP_ACTION_PREFIX + "catalogProductList", envelope);

                 response=(String) envelope.getResponse();
                 String sessionId = response.toString();
                 Log.d("The session Id is:",sessionId);

              SoapObject SingleProduct = new SoapObject(NAMESPACE, "shoppingCartProductEntity");
              PropertyInfo pi = new PropertyInfo();
              pi.setName("product_id");
              pi.setValue(Integer.parseInt(Products[0][0]));
              pi.setType(Integer.class);
              SingleProduct.addProperty(pi);

              pi = new PropertyInfo();
              pi.setName("sku");
              pi.setValue(Products[0][1]);
              pi.setType(String.class);
              SingleProduct.addProperty(pi);

              pi = new PropertyInfo();
              pi.setName("qty");
              pi.setValue(Products[0][2]);
              pi.setType(Double.class);
              SingleProduct.addProperty(pi);

              SoapObject EntityArray = new SoapObject(NAMESPACE, "shoppingCartProductEntityArray");
              EntityArray.addProperty("products",SingleProduct);


              request = new SoapObject(NAMESPACE,METHOD_NAME);
              //adding the propery such as sessionId and Customerdata for request
              request.addProperty("sessionId",sessionId );
              request.addProperty("quoteId",100);
              request.addProperty("products",EntityArray);
              request.addProperty("options",null);
              request.addProperty("bundle_option",null);
              request.addProperty("bundle_option_qty",null);
              request.addProperty("links",null);         
              //request.addProperty("store_id", 1);
              envelope.setOutputSoapObject(request);
              transport.call(NAMESPACE + SOAP_ACTION_PREFIX + METHOD_NAME, envelope);
              //getting the response which is the customerId
              Log.d("Test", "request: " + transport.requestDump);
              Log.d("Test", "response: " + transport.responseDump);
               }

                 catch (IOException e)
                      {
                    e.printStackTrace();
                      } 
                 catch (XmlPullParserException e)
                      {
                    e.printStackTrace();
                      }

【问题讨论】:

    标签: android magento ksoap2 android-ksoap2 ksoap


    【解决方案1】:

    shoppingCartProductAdd 方法只有 4 个参数 会话标识, 报价单, 产品\产品数据, storeId(可选)

    ,但你发送的不止于此,所以删除

     request.addProperty("options",null);
     request.addProperty("bundle_option",null);
     request.addProperty("bundle_option_qty",null);
     request.addProperty("links",null);   
    

    从您的代码中尝试。

    您可以根据需要将这些属性添加到 shoppingCartProductEntity 方法中。 http://www.magentocommerce.com/api/soap/checkout/cartProduct/cart_product.add.html了解更多详情

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-06
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-18
      • 2014-12-17
      • 1970-01-01
      相关资源
      最近更新 更多