Search code examples
magentosoapmagento-soap-api

How to fetch the magento order list with filter using SOAP API in android?


It's always returning completed orders only in android.

How to write this php code in android to fetch the results

$filters = array(array(
            'filter' => array(
                array(
                    'key' => 'status',
                    'value' => 'pending'
                ))));

to send in soap client

request = new SoapObject(NAMESPACE, "salesOrderList");
request.addProperty("sessionId",sessionId );
request.addProperty("filters", filters);

Solution

  • You can do the following using ksoap2-android library in android

    // NAMESPACE - specify your namespace
    // sessionId - get by calling the login web service
    // SALES_ORDER_LIST - web service to get sales order list
    
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = false;
    envelope.xsd = SoapSerializationEnvelope.XSD;
    envelope.enc = SoapSerializationEnvelope.ENC;
    
    SoapObject entity = new SoapObject(NAMESPACE, "associativeEntity");
    entity.addProperty("key", "status");
    entity.addProperty("value", "processing");
    
    SoapObject filter = new SoapObject(NAMESPACE, "associativeArray");
    array.addProperty("associativeEntity", entity);
    
    SoapObject filters = new SoapObject(NAMESPACE, "filters");
    filter.addProperty("filter", filters);
    
    SoapObject salesOrderList = new SoapObject(NAMESPACE, "salesOrderList");
    requestCart.addProperty("sessionId", sessionId);
    requestCart.addProperty("filters", filters);
    
    env.setOutputSoapObject(salesOrderList);
    androidHttpTransport.call(SALES_ORDER_LIST, envelope);
    
    result = env.getResponse();
    Log.d("List of Products", result.toString());