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

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


The following commit(s) were added to refs/heads/release24.09 by this push:
     new d6c2b7d9fd Keep the config item of a restored ProductConfigWrapper and 
drop a duplicate price call
d6c2b7d9fd is described below

commit d6c2b7d9fdce5bb32058f36d7caa1cc6147ef72b
Author: Mridul Pathak <[email protected]>
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 ce8b3e0a74..148885c01e 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);

Reply via email to