svn commit: r900760 - /ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/cart/ShowCart.groovy

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

svn commit: r900760 - /ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/cart/ShowCart.groovy

ashish-18
Author: ashish
Date: Tue Jan 19 13:06:46 2010
New Revision: 900760

URL: http://svn.apache.org/viewvc?rev=900760&view=rev
Log:
Applied patch from jira issue OFBIZ-3417 - Add support for iterating shopping cart item in ShowCart.groovy.
Thanks Arpit & Vivek for the contribution.

Modified:
    ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/cart/ShowCart.groovy

Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/cart/ShowCart.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/cart/ShowCart.groovy?rev=900760&r1=900759&r2=900760&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/cart/ShowCart.groovy (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/cart/ShowCart.groovy Tue Jan 19 13:06:46 2010
@@ -23,6 +23,7 @@
 import org.ofbiz.order.shoppingcart.ShoppingCartEvents;
 import org.ofbiz.product.store.ProductStoreWorker;
 import org.ofbiz.entity.condition.*;
+import org.ofbiz.entity.util.EntityUtil;
 
 // Get the Cart and Prepare Size
 shoppingCart = ShoppingCartEvents.getCartObject(request);
@@ -55,3 +56,25 @@
 context.associatedProducts = associatedProducts;
 
 context.contentPathPrefix = CatalogWorker.getContentPathPrefix(request);
+
+//Get Cart Items
+shoppingCartItems = shoppingCart.items();
+
+if(shoppingCartItems) {
+    shoppingCartItems.each { shoppingCartItem ->
+        if (shoppingCartItem.getProductId()) {
+            if (shoppingCartItem.getParentProductId()) {
+                parentProductId = shoppingCartItem.getParentProductId();
+            } else {
+                parentProductId = shoppingCartItem.getProductId();
+            }
+            context.parentProductId = parentProductId;
+        }
+        productCategoryMembers = delegator.findList("ProductCategoryMember", EntityCondition.makeCondition("productId", EntityOperator.EQUALS, parentProductId), null, null, null, false);
+        if (productCategoryMembers) {
+            productCategoryMember = EntityUtil.getFirst(productCategoryMembers);
+            productCategory = productCategoryMember.getRelatedOne("ProductCategory");
+            context.productCategory = productCategory;
+        }
+    }
+}