[ofbiz-framework] branch trunk updated: Improved: Remove hard coded values from removePromotion

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] branch trunk updated: Improved: Remove hard coded values from removePromotion

Pawan Verma-2
This is an automated email from the ASF dual-hosted git repository.

pawan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new f365a9b  Improved: Remove hard coded values from removePromotion
f365a9b is described below

commit f365a9b7a0b450da3b14784f272b33f148533b56
Author: Pawan Verma <[hidden email]>
AuthorDate: Sat May 9 12:43:45 2020 +0530

    Improved: Remove hard coded values from removePromotion
   
    (OFBIZ-10376)
   
    Thanks: Shikha Jaiswal for your contribution.
---
 .../ofbiz/order/shoppingcart/ShoppingCartEvents.java      | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java
index 414916f..1986232 100644
--- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java
+++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java
@@ -106,17 +106,14 @@ public class ShoppingCartEvents {
             cart.getProductPromoCodesEntered().clear();
             GenericValue productPromoCode = null;
             try {
-                productPromoCode = dispatcher.getDelegator().findOne("ProductPromoCode", UtilMisc.toMap("productPromoCodeId", promoCodeId), false);
+                productPromoCode = cart.getDelegator().findOne("ProductPromoCode",
+                                                    UtilMisc.toMap("productPromoCodeId", promoCodeId), false);
                 if (!productPromoCode.isEmpty()) {
                     String productPromoId = productPromoCode.getString("productPromoId");
-                    GenericValue productPromoAction = null;
-                    Map<String, String> productPromoActionMap = new HashMap<>();
-                    productPromoActionMap.put("productPromoId", productPromoId);
-                    productPromoActionMap.put("productPromoRuleId", "01");
-                    productPromoActionMap.put("productPromoActionSeqId", "01");
-
-                    productPromoAction = dispatcher.getDelegator().findOne("ProductPromoAction", productPromoActionMap, false);
-                    if (!productPromoAction.isEmpty()) {
+
+                    long productPromoActionCount = EntityQuery.use(cart.getDelegator())
+                                    .from("ProductPromoAction").where("productPromoId", productPromoId).queryCount();
+                    if (productPromoActionCount > 0) {
                         int index = cart.getAdjustmentPromoIndex(productPromoId);
                         /*Remove order adjustment*/
                         if (index != -1) {