You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2011/09/01 11:19:56 UTC

svn commit: r1163959 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java

Author: hansbak
Date: Thu Sep  1 09:19:55 2011
New Revision: 1163959

URL: http://svn.apache.org/viewvc?rev=1163959&view=rev
Log:
The auto-save list still has the last item even it's removed from cart. So when user login again, the cart is loaded from the auto-save list which is wrong. fixed with this change

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java?rev=1163959&r1=1163958&r2=1163959&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java Thu Sep  1 09:19:55 2011
@@ -406,11 +406,21 @@ public class ShoppingListEvents {
                 autoSaveListId = getAutoSaveListId(delegator, dispatcher, null, userLogin, cart.getProductStoreId());
                 cart.setAutoSaveListId(autoSaveListId);
             }
+            GenericValue shoppingList = delegator.findByPrimaryKey("ShoppingList", UtilMisc.toMap("shoppingListId", autoSaveListId));
+            Integer currentListSize = 0;
+            if (UtilValidate.isNotEmpty(shoppingList)) {
+                List<GenericValue> shoppingListItems = shoppingList.getRelated("ShoppingListItem");
+                if (UtilValidate.isNotEmpty(shoppingListItems)) {
+                    currentListSize = shoppingListItems.size();
+                }
+            }
 
             try {
                 String[] itemsArray = makeCartItemsArray(cart);
                 if (itemsArray != null && itemsArray.length != 0) {
                     addBulkFromCart(delegator, dispatcher, cart, userLogin, autoSaveListId, null, itemsArray, false, false);
+                }else if(itemsArray.length == 0 && currentListSize != 0){
+                    clearListInfo(delegator, autoSaveListId);
                 }
             } catch (IllegalArgumentException e) {
                 throw new GeneralException(e.getMessage(), e);