Author: doogie
Date: Tue May  4 21:19:41 2010
New Revision: 941048

URL: http://svn.apache.org/viewvc?rev=941048&view=rev
Log:
Add flag to ProductPromoAction, that tells PROMO_GWP to use all
available item quantities as the new GWP quantity.  This requires the
quantity field to be null, and useCartQuantity to be 'Y'.  This allows
insanely huge quantities to be used on items that have GWP promos
attached.  Under testing, I've added products with a quantity of 10000
and 50000 items, with no variation in speed.

Modified:
    
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
    ofbiz/trunk/applications/product/entitydef/entitymodel.xml
    
ofbiz/trunk/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl

Modified: 
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java?rev=941048&r1=941047&r2=941048&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
 (original)
+++ 
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
 Tue May  4 21:19:41 2010
@@ -1266,7 +1266,24 @@ public class ProductPromoWorker {
                 if (Debug.verboseOn()) Debug.logVerbose("Not adding promo 
item, already there; action: " + productPromoAction, module);
                 actionResultInfo.ranAction = false;
             } else {
-                BigDecimal quantity = productPromoAction.get("quantity") == 
null ? BigDecimal.ZERO : productPromoAction.getBigDecimal("quantity");
+                BigDecimal quantity;
+                if (productPromoAction.get("quantity") != null) {
+                    quantity = productPromoAction.getBigDecimal("quantity");
+                } else {
+                    if ("Y".equals(productPromoAction.get("useCartQuantity"))) 
{
+                        quantity = BigDecimal.ZERO;
+                        List used = getCartItemsUsed(cart, productPromoAction);
+                        Iterator usedIt = used.iterator();
+                        while (usedIt.hasNext()) {
+                            ShoppingCartItem item = (ShoppingCartItem) 
usedIt.next();
+                            BigDecimal available = 
item.getPromoQuantityAvailable();
+                            quantity = 
quantity.add(available).add(item.getPromoQuantityCandidateUseActionAndAllConds(productPromoAction));
+                            item.addPromoQuantityCandidateUse(available, 
productPromoAction, false);
+                        }
+                    } else {
+                        quantity = BigDecimal.ZERO;
+                    }
+                }
 
                 List optionProductIds = FastList.newInstance();
                 String productId = productPromoAction.getString("productId");

Modified: ofbiz/trunk/applications/product/entitydef/entitymodel.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/entitydef/entitymodel.xml?rev=941048&r1=941047&r2=941048&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/product/entitydef/entitymodel.xml Tue May  4 
21:19:41 2010
@@ -3392,6 +3392,7 @@ under the License.
       <field name="amount" type="fixed-point"></field>
       <field name="productId" type="id"></field>
       <field name="partyId" type="id"></field>
+      <field name="useCartQuantity" type="indicator"></field>
       <prim-key field="productPromoId"/>
       <prim-key field="productPromoRuleId"/>
       <prim-key field="productPromoActionSeqId"/>

Modified: 
ofbiz/trunk/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl?rev=941048&r1=941047&r2=941048&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl 
(original)
+++ 
ofbiz/trunk/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl 
Tue May  4 21:19:41 2010
@@ -280,6 +280,18 @@ under the License.
                                         
${uiLabelMap.ProductItemId}:&nbsp;<input type="text" size="15" name="productId" 
value="${(productPromoAction.productId)?if_exists}" />
                                         ${uiLabelMap.PartyParty}:&nbsp;<input 
type="text" size="10" name="partyId" 
value="${(productPromoAction.partyId)?if_exists}" />
                                         ${uiLabelMap.ServiceName}:&nbsp;<input 
type="text" size="20" name="serviceName" 
value="${(productPromoAction.serviceName)?if_exists}" />
+                                        ${uiLabelMap.UseCartQuantity}:&nbsp;
+                                        <select name="useCartQuantity">
+                                        <#if 
(productPromoAction.useCartQuantity)?exists>
+                                            <#assign productPromoActionCurEnum 
= productPromoAction.getRelatedOneCache("ActionEnumeration")>
+                                            <option 
value="${(productPromoAction.useCartQuantity)?if_exists}"><#if 
(productPromoAction.useCartQuantity.equal("Y"))>${uiLabelMap.CommonY}<#else>${uiLabelMap.CommonN}</#if></option>
+                                            <option 
value="${(productPromoAction.useCartQuantity)?if_exists}">&nbsp;</option>
+                                        <#else>
+                                            <option value="">&nbsp;</option>
+                                        </#if>
+                                            <option 
value="N">${uiLabelMap.CommonN}</option>
+                                            <option 
value="Y">${uiLabelMap.CommonY}</option>
+                                        </select>
                                         <input type="submit" 
value="${uiLabelMap.CommonUpdate}" />
                                     </form>
                                     </div>
@@ -394,6 +406,11 @@ under the License.
                                         
${uiLabelMap.ProductItemId}:&nbsp;<input type="text" size="15" name="productId" 
/>
                                         ${uiLabelMap.PartyParty}:&nbsp;<input 
type="text" size="10" name="partyId" />
                                         ${uiLabelMap.ServiceName}:&nbsp;<input 
type="text" size="20" name="serviceName" />
+                                        ${uiLabelMap.UseCartQuantity}:&nbsp;
+                                        <select name="useCartQuantity">
+                                            <option 
value="N">${uiLabelMap.CommonN}</option>
+                                            <option 
value="Y">${uiLabelMap.CommonY}</option>
+                                        </select>
                                         <input type="submit" 
value="${uiLabelMap.CommonCreate}" />
                                     </form>
                                     </div>


Reply via email to