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

AdminCustomerSearch

Started by fjbarrena, February 10, 2010, 10:30:33 am

Previous topic - Next topic

fjbarrena

Hi all,

i'm trying to search a customer who have in Customer.Custom3 a value. I'm using a hook before an Order saved.

He're the code:

AdminCustomerSearch searchCriteria = new AdminCustomerSearch();

searchCriteria.setId(KonakartAdminConstants.NOT_SET);
searchCriteria.setPromotionId(KonakartAdminConstants.NOT_SET);
searchCriteria.setEnabled(1);
searchCriteria.setType(KonakartAdminConstants.NOT_SET);
searchCriteria.setNotifiedProductId(KonakartAdminConstants.NOT_SET);
searchCriteria.setGroupId(KonakartAdminConstants.NOT_SET);
               
// searchCriteria.setExpressionName?
               
searchCriteria.setCustom3(customerIdInvitador);
                        
// Get results
AdminCustomerSearchResult customersSearch = eng.getCustomers(sessionId, searchCriteria, 1, 1);
               
// Only get 1 result (or zero)
AdminCustomer customers[] = customersSearch.getCustomers();
               
if (customers.length == 1) {
   // TODO: El destinatario se obtiene del getCustomers con el debido searchCriteria
         
   log.debug(customers[0].getEmailAddr() + " coupon" + couponCode);
}

With this code i don't get any result, but in my konakart database i have a customer who reach the search criteria.

I'm missing something in my code?
I'm wrong in something?

Thanks in advance.

Best regards

heidi

You'll probably get some clues if you enable the database logging so see which queries are generated.

So in konakart-logging.properties set logging like this:


log4j.logger.org.apache.torque.util.BasePeer  = DEBUG
log4j.logger.com.workingdogs.village          = DEBUG


fjbarrena

Thanks for the reply heidi.

I've find the problem, when I invoke

AdminCustomerSearchResult customersSearch = eng.getCustomers(sessionId, searchCriteria, 1, 1);

the offset was 1.

Well, i'm obtaining only 1 result for my search criteria... then... 1 result, with offset 1... the result is 0 results.

I've changed for:

AdminCustomerSearchResult customersSearch = eng.getCustomers(sessionId, searchCriteria, 0, 1);

and works fine.

Bye!