diff --git a/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java b/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java index 929caf9e1..3534de3fd 100644 --- a/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java +++ b/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java @@ -32,6 +32,7 @@ import org.ofbiz.base.util.UtilMisc; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.product.product.ProductWorker; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; @@ -41,39 +42,19 @@ public class FacilityServices { public static final String module = FacilityServices.class.getName(); - public static Map findProductsById(DispatchContext dctx, Map context) { + public static Map findProductsById(DispatchContext dctx, Map context) { GenericDelegator delegator = dctx.getDelegator(); String facilityId = (String) context.get("facilityId"); String idValue = (String) context.get("idValue"); GenericValue product = null; - List productsFound = null; + List productsFound = null; - GenericValue productItem = null; - if (UtilValidate.isNotEmpty(idValue)) { - // First lets find the productId from the Sku(s) - try { - productsFound = delegator.findByAnd("GoodIdentificationAndProduct", - UtilMisc.toMap("idValue", idValue), UtilMisc.toList("productId")); - } catch (GenericEntityException e) { - Debug.logError(e, module); - throw new GeneralRuntimeException(e.getMessage()); - } - } - - // Now do a direct lookup.. - productItem = null; try { - productItem = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", idValue)); + productsFound = ProductWorker.findProductsById(delegator, idValue, null, false, true); } catch (GenericEntityException e) { Debug.logError(e, module); throw new GeneralRuntimeException(e.getMessage()); } - if (productItem != null) { - if (productsFound == null) { - productsFound = new ArrayList(); - } - productsFound.add(productItem); - } // Send back the results Map result = ServiceUtil.returnSuccess(); diff --git a/pos/src/org/ofbiz/pos/PosTransaction.java b/pos/src/org/ofbiz/pos/PosTransaction.java index 190140e01..935e2a497 100644 --- a/pos/src/org/ofbiz/pos/PosTransaction.java +++ b/pos/src/org/ofbiz/pos/PosTransaction.java @@ -63,6 +63,7 @@ import org.ofbiz.pos.screen.PosScreen; import org.ofbiz.pos.screen.SaveSale; import org.ofbiz.product.config.ProductConfigWrapper; import org.ofbiz.product.config.ProductConfigWrapper.ConfigOption; +import org.ofbiz.product.product.ProductWorker; import org.ofbiz.product.store.ProductStoreWorker; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; @@ -192,15 +193,7 @@ public class PosTransaction implements Serializable { } public List lookupItem(String sku) throws GeneralException { - // first check for the product - GenericValue product = session.getDelegator().findByPrimaryKey("Product", UtilMisc.toMap("productId", sku)); - if (product != null) { - return UtilMisc.toList(product); - } else { - // not found; so we move on to GoodIdentification - return session.getDelegator().findByAnd("GoodIdentificationAndProduct", - UtilMisc.toMap("idValue", sku), UtilMisc.toList("productId")); - } + return ProductWorker.findProductsById( session.getDelegator(), sku, null); } public String getOrderId() {