You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mr...@apache.org on 2026/10/30 10:43:48 UTC

(ofbiz-framework) branch trunk updated: Keep the config item of a restored ProductConfigWrapper and drop a duplicate price call

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

mridulpathak 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 af50c9664b Keep the config item of a restored ProductConfigWrapper and drop a duplicate price call
af50c9664b is described below

commit af50c9664ba9f9c26388c42fc3d3d190f2abb668
Author: Mridul Pathak <mr...@gmail.com>
AuthorDate: Fri Oct 30 15:39:45 2026 +0530

    Keep the config item of a restored ProductConfigWrapper and drop a duplicate price call
    
    ConfigItem.configItem was declared transient, although GenericValue is serializable, so once a ProductConfigWrapper had been deserialized, isSingleChoice, getQuestion, getDescription and toString failed with a NullPointerException. The field is now serialized like configItemAssoc next to it. ConfigOption.recalculateOptionPrice also called calculateProductPrice twice with the same arguments and checked only the second result for errors; it now makes the call once, checks that result, a [...]
---
 .../org/apache/ofbiz/product/config/ProductConfigWrapper.java | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java
index f9d0230744..1e5c3c0e7f 100644
--- a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java
+++ b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java
@@ -501,7 +501,7 @@ public class ProductConfigWrapper implements Serializable {
     }
 
     public class ConfigItem implements java.io.Serializable {
-        private transient GenericValue configItem = null;
+        private GenericValue configItem = null;
         private GenericValue configItemAssoc = null;
         private transient ProductConfigItemContentWrapper content = null;
         private List<ConfigOption> options = null;
@@ -848,7 +848,7 @@ public class ProductConfigWrapper implements Serializable {
                 String variantProductId = componentOptions.get(oneComponent.getString("productId"));
 
                 if (UtilValidate.isNotEmpty(variantProductId)) {
-                    oneComponentProduct = EntityQuery.use(delegator).from("Product").where("productId", variantProductId).queryOne();
+                    oneComponentProduct = EntityQuery.use(pcw.getDelegator()).from("Product").where("productId", variantProductId).queryOne();
                 }
 
                 // Get the component's price
@@ -856,9 +856,8 @@ public class ProductConfigWrapper implements Serializable {
                         pcw.webSiteId, "currencyUomId", pcw.currencyUomId, "productPricePurposeId", "COMPONENT_PRICE", "autoUserLogin",
                         pcw.autoUserLogin, "productStoreId", productStoreId);
                 Map<String, Object> priceMap = pcw.getDispatcher().runSync("calculateProductPrice", fieldMap);
-                Map<String, Object> purchasePriceResultMap = dispatcher.runSync("calculateProductPrice", fieldMap);
-                if (ServiceUtil.isError(purchasePriceResultMap)) {
-                    String errorMessage = ServiceUtil.getErrorMessage(purchasePriceResultMap);
+                if (ServiceUtil.isError(priceMap)) {
+                    String errorMessage = ServiceUtil.getErrorMessage(priceMap);
                     throw new GeneralException(errorMessage);
                 }
                 BigDecimal componentListPrice = (BigDecimal) priceMap.get("listPrice");
@@ -880,7 +879,7 @@ public class ProductConfigWrapper implements Serializable {
                     }
                 } else {
                     fieldMap.put("productPricePurposeId", "PURCHASE");
-                    purchasePriceResultMap = pcw.getDispatcher().runSync("calculateProductPrice", fieldMap);
+                    Map<String, Object> purchasePriceResultMap = pcw.getDispatcher().runSync("calculateProductPrice", fieldMap);
                     if (ServiceUtil.isError(purchasePriceResultMap)) {
                         String errorMessage = ServiceUtil.getErrorMessage(purchasePriceResultMap);
                         throw new GeneralException(errorMessage);