svn commit: r912544 - in /ofbiz/trunk: applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ applications/product/servicedef/ applications/product/src/org/ofbiz/product/product/ specialpurpose/ecommerce/webapp/ecommerce/catalog/

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

svn commit: r912544 - in /ofbiz/trunk: applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ applications/product/servicedef/ applications/product/src/org/ofbiz/product/product/ specialpurpose/ecommerce/webapp/ecommerce/catalog/

ashish-18
Author: ashish
Date: Mon Feb 22 12:14:35 2010
New Revision: 912544

URL: http://svn.apache.org/viewvc?rev=912544&view=rev
Log:
Applied patch from jira issue OFBIZ-3493 -   OFBiz Improvement on ecommerce product detail page for showing out of stock product.
Thanks Parimal & Pranay for the contribution.

Modified:
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ProductDetail.groovy
    ofbiz/trunk/applications/product/servicedef/services_view.xml
    ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java
    ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ProductDetail.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ProductDetail.groovy?rev=912544&r1=912543&r2=912544&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ProductDetail.groovy (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ProductDetail.groovy Mon Feb 22 12:14:35 2010
@@ -255,6 +255,10 @@
                     context.variantTree = variantTree;
                     context.variantTreeSize = variantTree.size();
                 }
+                unavailableVariants = variantTreeMap.unavailableVariants;
+                if (unavailableVariants) {
+                    context.unavailableVariants = unavailableVariants;
+                }
                 if (imageMap) {
                     context.variantSample = imageMap;
                     context.variantSampleKeys = imageMap.keySet();
@@ -401,6 +405,19 @@
         }
     }
 
+    //get last inventory count from product facility for the product
+    facilities = delegator.findList("ProductFacility", EntityCondition.makeCondition([productId : product.productId]), null, null, null, false);
+    availableInventory = 0.0;
+    if(facilities) {
+        facilities.each { facility ->
+            lastInventoryCount = facility.lastInventoryCount;
+            if (lastInventoryCount != null && availableInventory.compareTo(lastInventoryCount) != 0) {
+                availableInventory += lastInventoryCount;
+            }
+        }
+    }
+    context.availableInventory = availableInventory;
+
     // get product associations
     alsoBoughtProducts = dispatcher.runSync("getAssociatedProducts", [productId : productId, type : "ALSO_BOUGHT", checkViewAllow : true, prodCatalogId : currentCatalogId, bidirectional : true, sortDescending : true]);
     context.alsoBoughtProducts = alsoBoughtProducts.assocProducts;

Modified: ofbiz/trunk/applications/product/servicedef/services_view.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_view.xml?rev=912544&r1=912543&r2=912544&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_view.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services_view.xml Mon Feb 22 12:14:35 2010
@@ -53,6 +53,7 @@
         <attribute name="productStoreId" type="String" mode="IN" optional="true"/>
         <attribute name="checkInventory" type="Boolean" mode="IN" default-value="true" optional="true"/>
         <attribute name="variantTree" type="java.util.Map" mode="OUT" optional="true"/>
+        <attribute name="unavailableVariants" type="java.util.List" mode="OUT" optional="true"/>
         <attribute name="variantSample" type="java.util.Map" mode="OUT" optional="true"/>
         <attribute name="virtualVariant" type="java.util.List" mode="OUT" optional="true"/>
     </service>

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java?rev=912544&r1=912543&r2=912544&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java Mon Feb 22 12:14:35 2010
@@ -208,6 +208,7 @@
             return ServiceUtil.returnSuccess();
         }
         List<String> items = FastList.newInstance();
+        List<GenericValue> outOfStockItems = FastList.newInstance();
 
         for (GenericValue variant: variants) {
             String productIdTo = variant.getString("productIdTo");
@@ -263,6 +264,8 @@
                         if (productTo.getString("isVirtual") != null && productTo.getString("isVirtual").equals("Y")) {
                             virtualVariant.add(productIdTo);
                         }
+                    } else {
+                        outOfStockItems.add(productTo);
                     }
                 } else {
                     items.add(productIdTo);
@@ -330,6 +333,9 @@
             return ServiceUtil.returnError(e.getMessage());
         }
 
+        if (outOfStockItems.size() > 0) {
+            result.put("unavailableVariants", outOfStockItems);
+        }
         result.put("variantSample", sample);
         result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
 

Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl?rev=912544&r1=912543&r2=912544&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl Mon Feb 22 12:14:35 2010
@@ -262,6 +262,22 @@
 //]]>
  </script>
 
+<#macro showUnavailableVarients>
+  <#if unavailableVariants?exists>
+    <ul>
+      <#list unavailableVariants as prod>
+        <#assign features = prod.getRelated("ProductFeatureAppl")/>
+        <li>
+          <#list features as feature>
+            <em>${feature.getRelatedOne("ProductFeature").description}</em><#if feature_has_next>, </#if>
+          </#list>
+          <span>${uiLabelMap.ProductItemOutOfStock}</span>
+        </li>
+      </#list>
+    </ul>
+  </#if>
+</#macro>
+
 <div id="productdetail">
 <#assign productAdditionalImage1 = productContentWrapper.get("ADDITIONAL_IMAGE_1")?if_exists />
 <#assign productAdditionalImage2 = productContentWrapper.get("ADDITIONAL_IMAGE_2")?if_exists />
@@ -496,21 +512,13 @@
             </div>
           <#else>
             <input type="hidden" name="add_product_id" value="NULL"/>
-            <div><strong>${uiLabelMap.ProductItemOutOfStock}.</strong></div>
             <#assign inStock = false />
           </#if>
          </#if>
         <#else>
           <input type="hidden" name="add_product_id" value="${product.productId}" />
-          <#assign isStoreInventoryNotAvailable = !(Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryAvailable(request, product, 1.0)) />
-          <#assign isStoreInventoryRequired = Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryRequired(request, product) />
-          <#if isStoreInventoryNotAvailable>
-            <#if isStoreInventoryRequired>
-              <div><strong>${uiLabelMap.ProductItemOutOfStock}.</strong></div>
-              <#assign inStock = false />
-            <#else>
-              <div><strong>${product.inventoryMessage?if_exists}</strong></div>
-            </#if>
+          <#if (availableInventory?exists) && (availableInventory <= 0)>
+            <#assign inStock = false />
           </#if>
         </#if>
         <#-- check to see if introductionDate hasnt passed yet -->
@@ -543,10 +551,19 @@
                 Number of rooms<input type="text" size="5" name="quantity" value="1"/>
               </div>
             <#else>
-                <input type="text" size="5" name="quantity" value="1"<#if product.isVirtual?if_exists?upper_case == "Y"> disabled="disabled"</#if> />
+              <span><input name="quantity" id="quantity" value="1" size="4" maxLength="4" type="text" <#if product.isVirtual!?upper_case == "Y">disabled="disabled"</#if> /></span><a href="javascript:addItem()" id="addToCart" name="addToCart" class="buttontext">${uiLabelMap.OrderAddToCart}</a>
+              <@showUnavailableVarients/>
             </#if>
-            <#-- This calls addItem() so that variants of virtual products cant be added before distinguishing features are selected, it should not be changed to additemSubmit() -->
-            <a href="javascript:addItem()" class="buttontext"><span style="white-space: nowrap;">${uiLabelMap.OrderAddToCart}</span></a>&nbsp;
+            <#else>
+              <#if productStore?exists>
+                <#if productStore.requireInventory?exists && productStore.requireInventory == "N">
+                  <span><input name="quantity" id="quantity" value="1" size="4" maxLength="4" type="text" <#if product.isVirtual!?upper_case == "Y">disabled="disabled"</#if> /></span><a href="javascript:addItem()" id="addToCart" name="addToCart" class="buttontext">${uiLabelMap.OrderAddToCart}</a>
+                  <@showUnavailableVarients/>
+                <#else>
+                  <span><input name="quantity" id="quantity" value="1" size="4" maxLength="4" type="text" disabled="disabled" /></span><a href="javascript:void(0);" disabled="disabled" class="buttontext">${uiLabelMap.OrderAddToCart}</a><br />
+                  <span>${uiLabelMap.ProductItemOutOfStock}<#if product.inventoryMessage?exists>&mdash; ${product.inventoryMessage}</#if></span>
+                </#if>
+              </#if>
           </#if>
         </#if>
         </fieldset>