2

I am using magento api "shoppingCartProductRemove" to remove an item from cart. In "shoppingCartProductEntity" it needs "associativeArray". How to create "associativeArray" and what are the Product custom options in that. I am trying

SoapObject item = new SoapObject(NAMESPACE,"shoppingCartProductEntity");
                PropertyInfo pinfo = new PropertyInfo();
                String productid = productId.get(deleteProductPosition);
                pinfo.setName("product_id");
                pinfo.setValue(productid);
                pinfo.setType(String.class);
                item.addProperty(pinfo);

                pinfo = new PropertyInfo();
                String productsku = productSku.get(deleteProductPosition);
                pinfo.setName("sku");
                pinfo.setValue(productsku);
                pinfo.setType(String.class);
                item.addProperty(pinfo);

                pinfo = new PropertyInfo();
                int productQty = Qty.get(deleteProductPosition);
                pinfo.setName("qty");
                pinfo.setValue(productQty);
                pinfo.setType(Double.class);
                item.addProperty(pinfo);


                Map<String, String> map = new HashMap<String, String>();

                map.put("key", "options");
                pinfo = new PropertyInfo();
                pinfo.setName("options");
                pinfo.setValue(map.get("key"));
                pinfo.setType(Map.class);
                item.addProperty(pinfo);

how to create Associative array with options, and what will be the setType of that array. Please let me know

Gopal Singh Sirvi
  • 4,539
  • 5
  • 33
  • 55

2 Answers2

1

First read this Module: Shopping Cart API

See the given sample code given on this url.

$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl'); 

$sessionId = $proxy->login('apiUser', 'apiKey'); 

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


var_dump($result)

Associative arrays are arrays that use named keys that you assign to them.

Refer these also for associative arrays:

Php Arrays

Added Reference links: (Java) As per my knowledge java does not support associative arrays, but you can achieve this by referring following urls.

Java associative arrays

Java or android associative arrays

Community
  • 1
  • 1
Mukesh
  • 7,630
  • 21
  • 105
  • 159
  • I tried these two things, but I am not able to put these in soap api to remove item from cart, could you please send the code if you are having to remove item from cart using soap api in android. –  Jun 24 '15 at 10:57
0

Hi I followed this link ,it din't worked for me.

I tried this code

SoapObject item = new SoapObject(NAMESPACE, "shoppingCartProductEntity");
                PropertyInfo pinfo = new PropertyInfo();


                pinfo.setName("product_id");
                pinfo.setValue(productId.get(deleteProductPosition));
                pinfo.setType(String.class);
                item.addProperty(pinfo);

                pinfo = new PropertyInfo();
                pinfo.setName("sku");
                pinfo.setValue(productSku.get(deleteProductPosition));
                pinfo.setType(String.class);
                item.addProperty(pinfo);
                int productQty = Qty.get(deleteProductPosition);
                pinfo = new PropertyInfo();
                pinfo.setName("qty");
                pinfo.setValue(productQty);
                pinfo.setType(Double.class);
                item.addProperty(pinfo);

                pinfo = new PropertyInfo();
                pinfo.setName("options");
                pinfo.setValue(" ");
                pinfo.setType(String[].class);
                item.addProperty(pinfo);


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

                SoapObject request = new SoapObject(NAMESPACE, "shoppingCartProductRemove");
                request.addProperty("sessionId", sessionId);
                request.addProperty("quoteId", 74);
                request.addProperty("products",EntityArray);

                env.setOutputSoapObject(request);
                androidHttpTransport = new HttpTransportSE(URL);
                androidHttpTransport.call("", env);

                Object result = (Boolean) env.getResponse();

its working for me .