KonaKart Community Forum

Installation / Configuration => Programming of KonaKart => Topic started by: giacomokk on July 27, 2017, 11:28:35 am

Title: AdminCustomer getAddresses() method always return null
Post by: giacomokk on July 27, 2017, 11:28:35 am
Hi, i'm trying to get all defined addresses for a customer using the AdminCustomer class method "getAddresses". but it always return "null". I'm sure that the customer has more than one addresses stored in the db table address_book.

Can you help me?

Regards,

G

Title: Re: AdminCustomer getAddresses() method always return null
Post by: julie on July 28, 2017, 03:13:29 pm
You should use the AdminApi call
public AdminAddressSearchResult getAddresses(String sessionId, AdminAddressSearch search,
            int offset, int size) throws KKAdminException;
Title: Re: AdminCustomer getAddresses() method always return null
Post by: giacomokk on July 28, 2017, 04:10:40 pm
Hi, yes i've tried in this way:

AdminAddressSearch aas = new AdminAddressSearch();
                     
aas.setCustomerId(customer.getId());
                                          
AdminAddressSearchResult aasResult = adminEng.getAddresses(sessionId, aas, 0, 100);
                     
AdminAddress[] addresses = aasResult.getAddresses();

but the result is the same: empty array.

How can i solve the problem?
Title: Re: AdminCustomer getAddresses() method always return null
Post by: giacomokk on July 31, 2017, 01:33:09 pm
The solution is to set this fields as null:

aas.setZoneId(-1);
                  
aas.setProductId(-1);
                  
aas.setManufacturerId(-1);
                  
aas.setCountryId(-1);
                  
aas.setId(-1);

Now i can get the addresses.
I think that is better if someone add this part to konakart documentation  ;)

G