try {
if (context.get("productStoreId") != null && context.get("productId") != null && context.get("folderId") != null) {
String productId = (String)context.get("productId");
String folderId = (String)context.get("folderId");
ReviseSellingManagerProductCall call = new ReviseSellingManagerProductCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
req = new ReviseSellingManagerProductRequestType();
SellingManagerProductDetailsType sellingManagerProductDetailsType = new SellingManagerProductDetailsType();
GenericValue ebayProductStoreInventory = delegator.findByPrimaryKey("EbayProductStoreInventory", UtilMisc.toMap("productId", productId, "facilityId", context.get("facilityId"), "productStoreId", context.get("productStoreId")));
Long ebayProductId = null;
if (ebayProductStoreInventory != null && ebayProductStoreInventory.getLong("ebayProductId") == null) {
Debug.logError("Can not update product "+productId+" has no ebay product Id in EbayProductStoreInventory. ", module);
return flag;
}
if (ebayProductStoreInventory != null && ebayProductStoreInventory.getLong("ebayProductId") != null) {
ebayProductId = ebayProductStoreInventory.getLong("ebayProductId");
}
sellingManagerProductDetailsType.setProductID(ebayProductId);
sellingManagerProductDetailsType.setProductName((delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId))).getString("internalName"));
//Must keep productId in SKU NUMBER because ebay allow productId field only long value.
sellingManagerProductDetailsType.setCustomLabel(productId);
if (ebayProductStoreInventory!=null) sellingManagerProductDetailsType.setQuantityAvailable(ebayProductStoreInventory.getBigDecimal("availableToPromiseListing").intValue());
req.setSellingManagerProductDetails(sellingManagerProductDetailsType);
resp = (ReviseSellingManagerProductResponseType) call.execute(req);
if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
flag = true;
ebayProductStoreInventory.put("ebayProductId", ebayProductId);
ebayProductStoreInventory.put("folderId", folderId);
ebayProductStoreInventory.store();