svn commit: r611121 - in /ofbiz/trunk/applications/product: script/org/ofbiz/product/inventory/InventoryServices.xml servicedef/services_view.xml src/org/ofbiz/product/product/ProductServices.java

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

svn commit: r611121 - in /ofbiz/trunk/applications/product: script/org/ofbiz/product/inventory/InventoryServices.xml servicedef/services_view.xml src/org/ofbiz/product/product/ProductServices.java

hansbak-2
Author: hansbak
Date: Fri Jan 11 01:21:09 2008
New Revision: 611121

URL: http://svn.apache.org/viewvc?rev=611121&view=rev
Log:
update for jira issues 1566,1567,1568 to discontinue selling variants when run out of stock when the product indicator is set and when there are no variants connected discontinue the virtual product too.

Modified:
    ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
    ofbiz/trunk/applications/product/servicedef/services_view.xml
    ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java

Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml?rev=611121&r1=611120&r2=611121&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml Fri Jan 11 01:21:09 2008
@@ -389,6 +389,23 @@
         <set from-field="parameters.productId" field="productIdMap.productId"/>
         <find-by-primary-key entity-name="Product" map-name="productIdMap" value-name="product"/>
         <now-timestamp-to-env env-name="nowTimestamp"/>
+
+        <!-- if discontinueProductSales field is empty and the product is a variant, get the fieldcontent from the virtual product -->
+        <if-not-empty field-name="product">
+            <if-compare field-name="product.isVariant" value="Y" operator="equals">
+                <!-- retrieve related virtual product because also to be used later -->
+                <set field="getAssoc.productIdTo" from-field="product.productId"/>
+                <set field="getAssoc.productAssocTypeId" value="PRODUCT_VARIANT"/>
+                <find-by-and entity-name="ProductAssoc" map-name="getAssoc" list-name="assocs"/>
+                <filter-list-by-date list-name="assocs" to-list-name="assocsDate"/>
+                <first-from-list entry-name="assoc" list-name="assocsDate"/>
+                <get-related-one value-name="assoc" relation-name="MainProduct" to-value-name="virtProduct"/>
+                <if-empty field-name="product.salesDiscWhenNotAvail">
+                    <set field="product.salesDiscWhenNotAvail" from-field="virtProduct.salesDiscWhenNotAvail"/>
+                </if-empty>
+            </if-compare>
+        </if-not-empty>
+        
         <!-- before checking inventory availability see if the product is already discontinued, and discontinued in the past (if in the future, still check availability and discontinue now if necessary) -->
         <if>
             <condition>
@@ -410,6 +427,21 @@
                     <set from-field="parameters.productId" field="discontinueProductSalesMap.productId"/>
                     <call-service service-name="discontinueProductSales" in-map-name="discontinueProductSalesMap"/>
                 </if-compare>
+                                
+                <!-- check if related virtual product has no variant left, if yes discontinue the virtual product too when salesDiscWhenNotAvail is 'Y'-->
+                <if-not-empty field-name="virtProduct">
+                    <if-compare field-name="virtProduct.salesDiscWhenNotAvail" operator="equals" value="Y">
+                        <set field="getFromAssoc.productId" from-field="virtProduct.productId"/>
+                        <set field="getFromAssoc.productAssocTypeId" value="PRODUCT_VARIANT"/>
+                        <find-by-and entity-name="ProductAssoc" map-name="getFromAssoc" list-name="assocs"/>
+                        <filter-list-by-date list-name="assocs" to-list-name="assocsDate"/>
+                        <if-empty field-name="assocsDate">
+                            <set from-field="virtProduct.productId" field="discontinueProductSalesMap.productId"/>
+                            <call-service service-name="discontinueProductSales" in-map-name="discontinueProductSalesMap"/>
+                        </if-empty>
+                    </if-compare>
+                </if-not-empty>
+                
             </then>
         </if>
     </simple-method>

Modified: ofbiz/trunk/applications/product/servicedef/services_view.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_view.xml?rev=611121&r1=611120&r2=611121&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_view.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services_view.xml Fri Jan 11 01:21:09 2008
@@ -69,7 +69,7 @@
         <attribute name="checkViewAllow" type="Boolean" mode="IN" optional="true"/>
         <attribute name="prodCatalogId" type="String" mode="IN" optional="true"/>
         <attribute name="type" type="String" mode="IN"/>
-        <attribute name="assocProducts" type="java.util.Collection" mode="OUT"/>
+        <attribute name="assocProducts" type="java.util.Collection" mode="OUT" optional="true"/>
     </service>
     <service name="getProductFeatures" engine="java"
             location="org.ofbiz.product.product.ProductServices" invoke="prodGetFeatures">

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=611121&r1=611120&r2=611121&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 Fri Jan 11 01:21:09 2008
@@ -311,13 +311,8 @@
             return ServiceUtil.returnError(e.getMessage());
         }
         
-        if (sample == null || sample.size() == 0) {
-            result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR);
-            result.put(ModelService.ERROR_MESSAGE, UtilProperties.getMessage(resource,"productservices.feature_sample_came_back_empty", locale));
-        } else {
-            result.put("variantSample", sample);
-            result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
-        }
+        result.put("variantSample", sample);
+        result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
 
         return result;
     }