KonaKart Community Forum

Installation / Configuration => Programming of KonaKart => Topic started by: DispatchMediaGroup on August 22, 2011, 10:39:48 pm

Title: getOrdersPerCustomer getOrderArray returns nothing
Post by: DispatchMediaGroup on August 22, 2011, 10:39:48 pm
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);
}
Title: Re: getOrdersPerCustomer getOrderArray returns nothing
Post by: DispatchMediaGroup on August 24, 2011, 03:01:14 pm
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...
Title: Re: getOrdersPerCustomer getOrderArray returns nothing
Post by: kate on August 24, 2011, 06:22:23 pm
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?
Title: Re: getOrdersPerCustomer getOrderArray returns nothing
Post by: DispatchMediaGroup on August 24, 2011, 10:43:59 pm
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!
Title: Re: getOrdersPerCustomer getOrderArray returns nothing
Post by: kate on August 27, 2011, 02:23:42 pm
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.