This is an automated email from the ASF dual-hosted git repository. mbrohl 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 da3e353e51 Fixed: Apply orderItemAttributes when adding to Shoppingcart from addToCartFromOrder. (OFBIZ-12886) da3e353e51 is described below commit da3e353e51ac270c328c1f307d4c77ed356a8c75 Author: Elaheh Lolaki <elaheh.lol...@ecomify.de> AuthorDate: Wed Jan 31 17:43:28 2024 +0100 Fixed: Apply orderItemAttributes when adding to Shoppingcart from addToCartFromOrder. (OFBIZ-12886) --- .../order/shoppingcart/ShoppingCartHelper.java | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java index 18b3bfbeb1..67629629c1 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java @@ -364,10 +364,27 @@ public class ShoppingCartHelper { } } + // get order item attributes to transfer it to the new cart item + Map<String, String> orderItemAttributes = null; try { - this.cart.addOrIncreaseItem(UtilValidate.isNotEmpty(aggregatedProdId) ? aggregatedProdId : productId, amount, - orderItem.getBigDecimal("quantity"), null, null, null, null, null, null, null, catalogId, configWrapper, - orderItemTypeId, itemGroupNumber, null, dispatcher); + List<GenericValue> oiAttributes = orderItem.getRelated("OrderItemAttribute", null, null, false); + if (UtilValidate.isNotEmpty(oiAttributes)) { + orderItemAttributes = new HashMap<String, String>(); + for (GenericValue attrib : oiAttributes) { + if (UtilValidate.isNotEmpty(attrib.getString("attrValue"))) { + orderItemAttributes.put(attrib.getString("attrName"), attrib.getString( + "attrValue")); + } + } + } + } catch (GenericEntityException e) { + errorMsgs.add(e.getMessage()); + } + try { + this.cart.addOrIncreaseItem(UtilValidate.isNotEmpty(aggregatedProdId) ? aggregatedProdId + : productId, amount, orderItem.getBigDecimal("quantity"), + null, null, null, null, null, null, null, null, null, orderItemAttributes, catalogId, + configWrapper, orderItemTypeId, itemGroupNumber, null, dispatcher); noItems = false; } catch (CartItemModifyException | ItemNotFoundException e) { errorMsgs.add(e.getMessage());