Hello veryone,
I have an issue using the Admin webservices to retrieve a product based on the SKU. Whatever I try, it seems impossible to get the product.
public AdminProduct getProductBySku(String sku) throws ServiceException {
logger.debug("Searching adminproduct by sku: " + sku);
int languageId = -1;
try {
String session = kk_admin.login(loginname, password);
AdminDataDescriptor dataDesc = new AdminDataDescriptor();
dataDesc.setLimit(1);
AdminProductSearch search = new AdminProductSearch();
search.setWhereToSearch(0);
search.setCategoryId(-100);
search.setSearchCategoryTree(true);
search.setManufacturerId(-100);
search.setPromotionId(-100);
search.setProductType(-100);
search.setSku(sku);
search.setSkuRule(0);
AdminProducts results = kk_admin.searchForProducts(session, dataDesc, search, languageId);
if (results.getProductArray() != null & results.getProductArray().length == 1) {
return results.getProductArray()[0];
}
logger.warn("Adminproduct with sku not found: " + sku);
return null;
}
catch (RemoteException re) {
throw new ServiceException("Unable to find a product by SKU", re);
}
}
Does anyone know how to properly implement this?
Regards,
Kim
I have an issue using the Admin webservices to retrieve a product based on the SKU. Whatever I try, it seems impossible to get the product.
public AdminProduct getProductBySku(String sku) throws ServiceException {
logger.debug("Searching adminproduct by sku: " + sku);
int languageId = -1;
try {
String session = kk_admin.login(loginname, password);
AdminDataDescriptor dataDesc = new AdminDataDescriptor();
dataDesc.setLimit(1);
AdminProductSearch search = new AdminProductSearch();
search.setWhereToSearch(0);
search.setCategoryId(-100);
search.setSearchCategoryTree(true);
search.setManufacturerId(-100);
search.setPromotionId(-100);
search.setProductType(-100);
search.setSku(sku);
search.setSkuRule(0);
AdminProducts results = kk_admin.searchForProducts(session, dataDesc, search, languageId);
if (results.getProductArray() != null & results.getProductArray().length == 1) {
return results.getProductArray()[0];
}
logger.warn("Adminproduct with sku not found: " + sku);
return null;
}
catch (RemoteException re) {
throw new ServiceException("Unable to find a product by SKU", re);
}
}
Does anyone know how to properly implement this?
Regards,
Kim