• Welcome to KonaKart Community Forum. Please login or sign up.
 

getOrdersPerCustomer getOrderArray returns nothing

Started by DispatchMediaGroup, August 22, 2011, 10:39:48 pm

Previous topic - Next topic

DispatchMediaGroup

Hi KonaKarts,
    I'm having a bit of trouble here that I feel should be easily resolvable.  I'm making a web service call to my KonaKart server to get a list of all orders a specific customer has made.  Everything seems to be working okay, except that when I try to call getOrderArray(), it returns nothing.  You can see my code snippet below.  One thing to note here is that by calling getTotalNumOrders(), I can see that the WS engine does in fact know the correct number of orders, but when I try to get the actual array of orders, it gives me nothing.  Am I not utilizing the DataDescriptor correctly?


// CREATE DATA DESCRIPTOR FOR GETTING ORDERS BY ORDER DATE
DataDescriptor descriptor = new DataDescriptor();
descriptor.setOrderBy(DataDescConstants.ORDER_BY_DATE_ADDED_DESCENDING);

// USES CUSTOM METHOD FOR GETTING KK WS ENGINE
// ALSO USES CUSTOM METHOD FOR LOGGING IN A CUSTOMER
// -- BOTH OF THESE METHODS HAVE BEEN VALIDATED TO WORK AS EXPECTED
Orders orders = getKonaKartEngine().getOrdersPerCustomer(descriptor,
login(user), DEFAULT_LANGUAGE_ID);

if (LOG.isDebugEnabled())
{
        // THIS RETURNS THE CORRECT NUMBER OF ORDERS
LOG.debug("Number of orders (getTotalNumOrders) ... "
+ orders.getTotalNumOrders());

        // THIS RETURNS NOTHING (i.e. 0)
LOG.debug("Number of orders (orderArray.length) ... "
+ orders.getOrderArray().length);
}

DispatchMediaGroup

No one else knows anything about this?  The method call knows the correct number of Orders, but I cannot access them when I try to retrieve the array of Orders.  There has to be some stupid nuance I'm missing here.  And I'd really rather not write a bunch of SQL and build POJOs myself if the KK WS engine can already, ostensibly, do this for me...

kate

A good way to diagnose the problem for yourself is to turn on the SQL debugging so that you can see the queries being executed.

When you do that I imagine you will see that you need to set something in the DataDescriptor - maybe something like the Limit to something large?

DispatchMediaGroup

Thank you so much, kate!  As it turns out, the documentation had nothing that even hints that this would be the issue, but if you use a DataDescriptor, you must use setLimit() to get any actual objects back, although the method call getTotalNumProducts() will reflect the correct total amount of results you'd expect.

Again, thank you, kate; I'm sure this little tidbit will help others like myself.  If there was some sort of poster rating, I'd plus one ya!

kate

Quotethe documentation had nothing that even hints that this would be the issue, but if you use a DataDescriptor, you must use setLimit() to get any actual objects back


The javadoc for setLimit gives you a pretty good hint where it states:

void   setLimit(int limit)
          It defines the maximum number of objects returned.