Author: mor
Date: Mon May 25 16:37:23 2009 New Revision: 778451 URL: http://svn.apache.org/viewvc?rev=778451&view=rev Log: Adding back the feature to show/hide out of stock products on site. This new implementation is configurable through a new field showOutOfStockProducts (by default equal to Y) on ProductStore. A new field lastInventoryCount on ProductFacility is also added and it is a mirror of availableToPromiseTotal of a product at a certain point of time and is being updated every hour by a schedule service to reflect the current value of inventory count in the system. If showOutOfStockProducts is equals to N and for a particular product lastInventoryCount is <= zero, then this particular product will not be shown on the site. If the inventory count becomes +ve again then the product will be again available on the site, in minimum one hour time but could possibly take long depending on the inventory levels. Patch from Ratnesh Upadhyay, part of OFBIZ-2480 (https://issues.apache.org/jira/browse/OFBIZ-2480). Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/CategoryDetail.groovy ofbiz/trunk/applications/product/data/ProductScheduledServices.xml ofbiz/trunk/applications/product/entitydef/entitymodel.xml ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml ofbiz/trunk/applications/product/servicedef/services_facility.xml ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/CategoryDetail.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/CategoryDetail.groovy?rev=778451&r1=778450&r2=778451&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/CategoryDetail.groovy (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/CategoryDetail.groovy Mon May 25 16:37:23 2009 @@ -27,6 +27,7 @@ import org.ofbiz.service.*; import org.ofbiz.product.catalog.*; import org.ofbiz.product.category.CategoryContentWrapper; +import org.ofbiz.product.store.ProductStoreWorker; productCategoryId = request.getAttribute("productCategoryId"); context.productCategoryId = productCategoryId; @@ -59,7 +60,26 @@ catResult = dispatcher.runSync("getProductCategoryAndLimitedMembers", andMap); productCategory = catResult.productCategory; -context.productCategoryMembers = catResult.productCategoryMembers; +productCategoryMembers = catResult.productCategoryMembers; + +// Prevents out of stock product to be displayed on site +productStore = ProductStoreWorker.getProductStore(request); +if(productStore) { + if("N".equals(productStore.showOutOfStockProducts)) { + productsInStock = []; + productCategoryMembers.each { productCategoryMember -> + productFacility = delegator.findOne("ProductFacility", [productId : productCategoryMember.productId, facilityId : productStore.inventoryFacilityId], true); + if(productFacility) { + if(productFacility.lastInventoryCount >= 1) { + productsInStock.add(productCategoryMember); + } + } + } + context.productCategoryMembers = productsInStock; + } else { + context.productCategoryMembers = productCategoryMembers; + } +} context.productCategory = productCategory; context.viewIndex = catResult.viewIndex; context.viewSize = catResult.viewSize; Modified: ofbiz/trunk/applications/product/data/ProductScheduledServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductScheduledServices.xml?rev=778451&r1=778450&r2=778451&view=diff ============================================================================== --- ofbiz/trunk/applications/product/data/ProductScheduledServices.xml (original) +++ ofbiz/trunk/applications/product/data/ProductScheduledServices.xml Mon May 25 16:37:23 2009 @@ -21,6 +21,26 @@ <entity-engine-xml> <JobSandbox jobId="8100" jobName="Purge Old Store Auto-Entered Promos" runTime="2000-01-01 00:00:00.000" serviceName="purgeOldStoreAutoPromos" poolId="pool" runAsUser="system" tempExprId="MIDNIGHT_DAILY" maxRecurrenceCount="-1"/> + <RecurrenceRule recurrenceRuleId="500" untilDateTime="" frequency="HOURLY" intervalNumber="1" countNumber="-1"/> + <RecurrenceInfo recurrenceInfoId="500" startDateTime="2008-05-14 22:00:00.000" recurrenceRuleId="500" recurrenceCount="0"/> + <RuntimeData runtimeDataId="8801"> + <runtimeInfo><![CDATA[<?xml version="1.0" encoding="UTF-8"?> + <ofbiz-ser> + <map-HashMap> + <map-Entry> + <map-Key> + <std-String value="recurrenceInfoId"/> + </map-Key> + <map-Value> + <std-String value="500"/> + </map-Value> + </map-Entry> + </map-HashMap> + </ofbiz-ser> + ]]></runtimeInfo> + </RuntimeData> + <JobSandbox jobId="8801" jobName="Set Last Inventory Count on ProductFacility" runTime="2000-01-01 00:00:00.000" serviceName="setLastInventoryCount" runtimeDataId="8801" poolId="pool" runAsUser="system" recurrenceInfoId="500"/> + <!--Data for scheduling the service productImportFromSpreadsheet --> <!--RecurrenceRule recurrenceRuleId="500" untilDateTime="" frequency="MINUTELY" intervalNumber="5" countNumber="-1"/> <RecurrenceInfo recurrenceInfoId="500" startDateTime="2006-06-06 01:10:00.000" recurrenceRuleId="500" recurrenceCount="0"/> Modified: ofbiz/trunk/applications/product/entitydef/entitymodel.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/entitydef/entitymodel.xml?rev=778451&r1=778450&r2=778451&view=diff ============================================================================== --- ofbiz/trunk/applications/product/entitydef/entitymodel.xml (original) +++ ofbiz/trunk/applications/product/entitydef/entitymodel.xml Mon May 25 16:37:23 2009 @@ -1289,6 +1289,7 @@ <field name="minimumStock" type="fixed-point"></field> <field name="reorderQuantity" type="fixed-point"></field> <field name="daysToShip" type="numeric"></field> + <field name="lastInventoryCount" type="fixed-point"><description>This field represents availableToPromiseTotal of a product at a certain point of time and is being updated regularly by a schedule service every hour</description></field> <prim-key field="productId"/> <prim-key field="facilityId"/> <relation type="one" fk-name="PROD_FAC_PROD" rel-entity-name="Product"> @@ -3606,6 +3607,7 @@ <field name="addToCartRemoveIncompat" type="indicator"><description>Default N. If Y then on add to cart remove all products in cart with a ProductAssoc record related to or from the product and with the PRODUCT_INCOMPATABLE type.</description></field> <field name="addToCartReplaceUpsell" type="indicator"><description>Default N. If Y then on add to cart remove all products in cart with a ProductAssoc record related from the product and with the PRODUCT_UPGRADE type.</description></field> <field name="splitPayPrefPerShpGrp" type="indicator"><description>Default N. If Y then before the order is stored the OrderPaymentPreference record will be split, one for each OrderItemShipGroup.</description></field> + <field name="showOutOfStockProducts" type="indicator"><description>Default Y. If N then out of stock products will not be displayed on site</description></field> <prim-key field="productStoreId"/> <relation type="one" fk-name="PROD_STR_PRSTRGP" title="Primary" rel-entity-name="ProductStoreGroup"> <key-map field-name="primaryStoreGroupId" rel-field-name="productStoreGroupId"/> 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=778451&r1=778450&r2=778451&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 Mon May 25 16:37:23 2009 @@ -1293,4 +1293,20 @@ </else> </if-empty> </simple-method> + <simple-method method-name="setLastInventoryCount" short-description="Schedule service that updates stock availability of products hourly"> + <entity-condition entity-name="ProductFacility" list="productFacilities" use-cache="true"> + <use-iterator/> + </entity-condition> + <iterate list="productFacilities" entry="productFacility"> + <set field="serviceInMap.productId" from-field="productFacility.productId"/> + <call-service service-name="getProductInventoryAvailable" in-map-name="serviceInMap"> + <result-to-field result-name="availableToPromiseTotal"/> + </call-service> + <set field="productFacility.lastInventoryCount" from-field="availableToPromiseTotal"/> + <set-service-fields service-name="updateProductFacility" map="productFacility" to-map="productFacilityCtx"/> + <call-service service-name="updateProductFacility" in-map-name="productFacilityCtx"/> + <clear-field field="productFacility"/> + <clear-field field="productFacilityCtx"/> + </iterate> + </simple-method> </simple-methods> \ No newline at end of file Modified: ofbiz/trunk/applications/product/servicedef/services_facility.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_facility.xml?rev=778451&r1=778450&r2=778451&view=diff ============================================================================== --- ofbiz/trunk/applications/product/servicedef/services_facility.xml (original) +++ ofbiz/trunk/applications/product/servicedef/services_facility.xml Mon May 25 16:37:23 2009 @@ -890,4 +890,9 @@ <attribute name="productId" type="String" mode="IN" optional="false"/> <attribute name="LocationList" type="List" mode="OUT" optional="true"/> </service> + <service name="setLastInventoryCount" engine="simple" + location="component://product/script/org/ofbiz/product/inventory/InventoryServices.xml" invoke="setLastInventoryCount"> + <description>Schedule service that updates lastInventoryCount hourly for products available in facility</description> + <attribute name="recurrenceInfoId" mode="IN" type="String" optional="false"/> + </service> </services> Modified: ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml?rev=778451&r1=778450&r2=778451&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml (original) +++ ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml Mon May 25 16:37:23 2009 @@ -57,7 +57,7 @@ authFraudMessage="Your order has been rejected and your account has been disabled due to fraud." authErrorMessage="Problem connecting to payment processor; we will continue to retry and notify you by email." storeCreditValidDays="90" - visualThemeId="EC_DEFAULT" autoApproveInvoice="Y" shipIfCaptureFails="Y" autoApproveOrder="Y"/> + visualThemeId="EC_DEFAULT" autoApproveInvoice="Y" shipIfCaptureFails="Y" autoApproveOrder="Y" showOutOfStockProducts="Y"/> <!-- <ProductStorePaymentSetting productStoreId="9000" paymentMethodTypeId="CREDIT_CARD" paymentServiceTypeEnumId="PRDS_PAY_AUTH" paymentService="testRandomAuthorize"/> --> <ProductStorePaymentSetting productStoreId="9000" paymentMethodTypeId="CREDIT_CARD" paymentServiceTypeEnumId="PRDS_PAY_AUTH" paymentService="alwaysApproveCCProcessor" paymentCustomMethodId="CC_AUTH_ALWAYSAPPROV"/> |
Free forum by Nabble | Edit this page |