You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ar...@apache.org on 2016/11/02 19:09:18 UTC
svn commit: r1767764 [11/33] - in /ofbiz/trunk:
applications/accounting/groovyScripts/admin/
applications/accounting/groovyScripts/ap/invoices/
applications/accounting/groovyScripts/ar/
applications/accounting/groovyScripts/chartofaccounts/ application...
Modified: ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ProductDetail.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ProductDetail.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ProductDetail.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ProductDetail.groovy Wed Nov 2 19:09:13 2016
@@ -22,613 +22,613 @@
* should not contain order component's specific code.
*/
-import java.text.NumberFormat;
+import java.text.NumberFormat
-import org.apache.ofbiz.base.util.*;
-import org.apache.ofbiz.entity.*;
-import org.apache.ofbiz.entity.condition.*;
-import org.apache.ofbiz.entity.util.*;
-import org.apache.ofbiz.service.*;
-import org.apache.ofbiz.webapp.taglib.ContentUrlTag;
-import org.apache.ofbiz.product.product.ProductContentWrapper;
-import org.apache.ofbiz.product.product.ProductSearch;
-import org.apache.ofbiz.product.product.ProductSearchSession;
-import org.apache.ofbiz.product.product.ProductWorker;
-import org.apache.ofbiz.product.catalog.*;
-import org.apache.ofbiz.product.store.*;
-import org.apache.ofbiz.webapp.stats.VisitHandler;
+import org.apache.ofbiz.base.util.*
+import org.apache.ofbiz.entity.*
+import org.apache.ofbiz.entity.condition.*
+import org.apache.ofbiz.entity.util.*
+import org.apache.ofbiz.service.*
+import org.apache.ofbiz.webapp.taglib.ContentUrlTag
+import org.apache.ofbiz.product.product.ProductContentWrapper
+import org.apache.ofbiz.product.product.ProductSearch
+import org.apache.ofbiz.product.product.ProductSearchSession
+import org.apache.ofbiz.product.product.ProductWorker
+import org.apache.ofbiz.product.catalog.*
+import org.apache.ofbiz.product.store.*
+import org.apache.ofbiz.webapp.stats.VisitHandler
import org.apache.ofbiz.webapp.website.WebSiteWorker
-import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents;
-import org.apache.ofbiz.order.shoppingcart.ShoppingCart;
+import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents
+import org.apache.ofbiz.order.shoppingcart.ShoppingCart
String buildNext(Map map, List order, String current, String prefix, Map featureTypes) {
- def ct = 0;
- def buf = new StringBuffer();
- buf.append("function listFT" + current + prefix + "() { ");
- buf.append("document.forms[\"addform\"].elements[\"FT" + current + "\"].options.length = 1;");
- buf.append("document.forms[\"addform\"].elements[\"FT" + current + "\"].options[0] = new Option(\"" + featureTypes[current] + "\",\"\",true,true);");
+ def ct = 0
+ def buf = new StringBuffer()
+ buf.append("function listFT" + current + prefix + "() { ")
+ buf.append("document.forms[\"addform\"].elements[\"FT" + current + "\"].options.length = 1;")
+ buf.append("document.forms[\"addform\"].elements[\"FT" + current + "\"].options[0] = new Option(\"" + featureTypes[current] + "\",\"\",true,true);")
map.each { key, value ->
- def optValue = null;
+ def optValue = null
if (order.indexOf(current) == (order.size()-1)) {
- optValue = value.iterator().next();
+ optValue = value.iterator().next()
} else {
- optValue = prefix + "_" + ct;
+ optValue = prefix + "_" + ct
}
- buf.append("document.forms[\"addform\"].elements[\"FT" + current + "\"].options[" + (ct + 1) + "] = new Option(\"" + key + "\",\"" + optValue + "\");");
- ct++;
+ buf.append("document.forms[\"addform\"].elements[\"FT" + current + "\"].options[" + (ct + 1) + "] = new Option(\"" + key + "\",\"" + optValue + "\");")
+ ct++
}
- buf.append(" }");
+ buf.append(" }")
if (order.indexOf(current) < (order.size()-1)) {
- ct = 0;
+ ct = 0
map.each { key, value ->
- def nextOrder = order.get(order.indexOf(current)+1);
- def newPrefix = prefix + "_" + ct;
- buf.append(buildNext(value, order, nextOrder, newPrefix, featureTypes));
- ct++;
+ def nextOrder = order.get(order.indexOf(current)+1)
+ def newPrefix = prefix + "_" + ct
+ buf.append(buildNext(value, order, nextOrder, newPrefix, featureTypes))
+ ct++
}
}
- return buf.toString();
+ return buf.toString()
}
-cart = ShoppingCartEvents.getCartObject(request);
+cart = ShoppingCartEvents.getCartObject(request)
// set currency format
-currencyUomId = null;
-if (cart) currencyUomId = cart.getCurrency();
-if (!currencyUomId) currencyUomId = EntityUtilProperties.getPropertyValue("general", "currency.uom.id.default", "USD", delegator);
+currencyUomId = null
+if (cart) currencyUomId = cart.getCurrency()
+if (!currencyUomId) currencyUomId = EntityUtilProperties.getPropertyValue("general", "currency.uom.id.default", "USD", delegator)
// get the shopping lists for the user (if logged in)
if (userLogin) {
exprList = [EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, userLogin.partyId),
- EntityCondition.makeCondition("listName", EntityOperator.NOT_EQUAL, "auto-save")];
- allShoppingLists = from("ShoppingList").where(exprList).orderBy("listName").queryList();
- context.shoppingLists = allShoppingLists;
+ EntityCondition.makeCondition("listName", EntityOperator.NOT_EQUAL, "auto-save")]
+ allShoppingLists = from("ShoppingList").where(exprList).orderBy("listName").queryList()
+ context.shoppingLists = allShoppingLists
}
// set the content path prefix
-contentPathPrefix = CatalogWorker.getContentPathPrefix(request);
-context.contentPathPrefix = contentPathPrefix;
+contentPathPrefix = CatalogWorker.getContentPathPrefix(request)
+context.contentPathPrefix = contentPathPrefix
// get the product detail information
if (product) {
- productId = product.productId;
- context.product_id = productId;
- productTypeId = product.productTypeId;
+ productId = product.productId
+ context.product_id = productId
+ productTypeId = product.productTypeId
- boolean isMarketingPackage = EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.productTypeId, "parentTypeId", "MARKETING_PKG");
- context.isMarketingPackage = (isMarketingPackage? "true": "false");
+ boolean isMarketingPackage = EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.productTypeId, "parentTypeId", "MARKETING_PKG")
+ context.isMarketingPackage = (isMarketingPackage? "true": "false")
- featureTypes = [:];
- featureOrder = [];
+ featureTypes = [:]
+ featureOrder = []
// set this as a last viewed
- LAST_VIEWED_TO_KEEP = 10; // modify this to change the number of last viewed to keep
- lastViewedProducts = session.getAttribute("lastViewedProducts");
+ LAST_VIEWED_TO_KEEP = 10 // modify this to change the number of last viewed to keep
+ lastViewedProducts = session.getAttribute("lastViewedProducts")
if (!lastViewedProducts) {
- lastViewedProducts = [];
- session.setAttribute("lastViewedProducts", lastViewedProducts);
+ lastViewedProducts = []
+ session.setAttribute("lastViewedProducts", lastViewedProducts)
}
- lastViewedProducts.remove(productId);
- lastViewedProducts.add(0, productId);
+ lastViewedProducts.remove(productId)
+ lastViewedProducts.add(0, productId)
while (lastViewedProducts.size() > LAST_VIEWED_TO_KEEP) {
- lastViewedProducts.remove(lastViewedProducts.size() - 1);
+ lastViewedProducts.remove(lastViewedProducts.size() - 1)
}
// make the productContentWrapper
- productContentWrapper = new ProductContentWrapper(product, request);
- context.productContentWrapper = productContentWrapper;
+ productContentWrapper = new ProductContentWrapper(product, request)
+ context.productContentWrapper = productContentWrapper
// get the main detail image (virtual or single product)
- mainDetailImage = productContentWrapper.get("DETAIL_IMAGE_URL", "url");
+ mainDetailImage = productContentWrapper.get("DETAIL_IMAGE_URL", "url")
if (mainDetailImage) {
- mainDetailImageUrl = ContentUrlTag.getContentPrefix(request) + mainDetailImage;
- context.mainDetailImageUrl = mainDetailImageUrl.toString();
+ mainDetailImageUrl = ContentUrlTag.getContentPrefix(request) + mainDetailImage
+ context.mainDetailImageUrl = mainDetailImageUrl.toString()
}
// get next/previous information for category
- categoryId = parameters.category_id ?: product.primaryProductCategoryId;
- if (categoryId) context.categoryId = categoryId;
+ categoryId = parameters.category_id ?: product.primaryProductCategoryId
+ if (categoryId) context.categoryId = categoryId
- catNextPreviousResult = null;
+ catNextPreviousResult = null
if (categoryId) {
- prevNextMap = [categoryId : categoryId, productId : productId];
- prevNextMap.orderByFields = context.orderByFields ?: ["sequenceNum", "productId"];
- catNextPreviousResult = runService('getPreviousNextProducts', prevNextMap);
+ prevNextMap = [categoryId : categoryId, productId : productId]
+ prevNextMap.orderByFields = context.orderByFields ?: ["sequenceNum", "productId"]
+ catNextPreviousResult = runService('getPreviousNextProducts', prevNextMap)
if (ServiceUtil.isError(catNextPreviousResult)) {
- request.setAttribute("errorMessageList", [ServiceUtil.getErrorMessage(catNextPreviousResult)]);
- return;
+ request.setAttribute("errorMessageList", [ServiceUtil.getErrorMessage(catNextPreviousResult)])
+ return
}
if (catNextPreviousResult && catNextPreviousResult.category) {
- context.category = catNextPreviousResult.category;
- context.previousProductId = catNextPreviousResult.previousProductId;
- context.nextProductId = catNextPreviousResult.nextProductId;
+ context.category = catNextPreviousResult.category
+ context.previousProductId = catNextPreviousResult.previousProductId
+ context.nextProductId = catNextPreviousResult.nextProductId
}
}
// get the product store for only Sales Order not for Purchase Order.
- productStore = null;
- productStoreId = null;
- cart = ShoppingCartEvents.getCartObject(request);
+ productStore = null
+ productStoreId = null
+ cart = ShoppingCartEvents.getCartObject(request)
if (cart.isSalesOrder()) {
- productStore = ProductStoreWorker.getProductStore(request);
- productStoreId = productStore.productStoreId;
- context.productStoreId = productStoreId;
+ productStore = ProductStoreWorker.getProductStore(request)
+ productStoreId = productStore.productStoreId
+ context.productStoreId = productStoreId
}
// get a defined survey
- productSurvey = ProductStoreWorker.getProductSurveys(delegator, productStoreId, productId, "CART_ADD");
+ productSurvey = ProductStoreWorker.getProductSurveys(delegator, productStoreId, productId, "CART_ADD")
if (productSurvey) {
- survey = EntityUtil.getFirst(productSurvey);
- origParamMapId = UtilHttp.stashParameterMap(request);
- surveyContext = ["_ORIG_PARAM_MAP_ID_" : origParamMapId];
- surveyPartyId = userLogin?.partyId;
- wrapper = new ProductStoreSurveyWrapper(survey, surveyPartyId, surveyContext);
- context.surveyWrapper = wrapper;
+ survey = EntityUtil.getFirst(productSurvey)
+ origParamMapId = UtilHttp.stashParameterMap(request)
+ surveyContext = ["_ORIG_PARAM_MAP_ID_" : origParamMapId]
+ surveyPartyId = userLogin?.partyId
+ wrapper = new ProductStoreSurveyWrapper(survey, surveyPartyId, surveyContext)
+ context.surveyWrapper = wrapper
}
// get the product price
- catalogId = CatalogWorker.getCurrentCatalogId(request);
- currentCatalogId = catalogId;
- webSiteId = WebSiteWorker.getWebSiteId(request);
- autoUserLogin = request.getSession().getAttribute("autoUserLogin");
+ catalogId = CatalogWorker.getCurrentCatalogId(request)
+ currentCatalogId = catalogId
+ webSiteId = WebSiteWorker.getWebSiteId(request)
+ autoUserLogin = request.getSession().getAttribute("autoUserLogin")
if (cart.isSalesOrder()) {
// sales order: run the "calculateProductPrice" service
priceContext = [product : product, prodCatalogId : catalogId,
- currencyUomId : cart.getCurrency(), autoUserLogin : autoUserLogin];
- priceContext.webSiteId = webSiteId;
- priceContext.productStoreId = productStoreId;
- priceContext.checkIncludeVat = "Y";
- priceContext.agreementId = cart.getAgreementId();
- priceContext.partyId = cart.getPartyId(); // IMPORTANT: must put this in, or price will be calculated for the CSR instead of the customer
- priceMap = runService('calculateProductPrice', priceContext);
- context.priceMap = priceMap;
+ currencyUomId : cart.getCurrency(), autoUserLogin : autoUserLogin]
+ priceContext.webSiteId = webSiteId
+ priceContext.productStoreId = productStoreId
+ priceContext.checkIncludeVat = "Y"
+ priceContext.agreementId = cart.getAgreementId()
+ priceContext.partyId = cart.getPartyId() // IMPORTANT: must put this in, or price will be calculated for the CSR instead of the customer
+ priceMap = runService('calculateProductPrice', priceContext)
+ context.priceMap = priceMap
} else {
// purchase order: run the "calculatePurchasePrice" service
priceContext = [product : product, currencyUomId : cart.getCurrency(),
- partyId : cart.getPartyId(), userLogin : userLogin];
- priceMap = runService('calculatePurchasePrice', priceContext);
- context.priceMap = priceMap;
+ partyId : cart.getPartyId(), userLogin : userLogin]
+ priceMap = runService('calculatePurchasePrice', priceContext)
+ context.priceMap = priceMap
}
// get the product review(s)
// get all product review in case of Purchase Order.
- reviewByAnd = [:];
- reviewByAnd.statusId = "PRR_APPROVED";
+ reviewByAnd = [:]
+ reviewByAnd.statusId = "PRR_APPROVED"
if (cart.isSalesOrder()) {
- reviewByAnd.productStoreId = productStoreId;
+ reviewByAnd.productStoreId = productStoreId
}
- reviews = product.getRelated("ProductReview", reviewByAnd, ["-postedDateTime"], true);
- context.productReviews = reviews;
+ reviews = product.getRelated("ProductReview", reviewByAnd, ["-postedDateTime"], true)
+ context.productReviews = reviews
// get the average rating
if (reviews) {
- ratingReviews = EntityUtil.filterByAnd(reviews, [EntityCondition.makeCondition("productRating", EntityOperator.NOT_EQUAL, null)]);
+ ratingReviews = EntityUtil.filterByAnd(reviews, [EntityCondition.makeCondition("productRating", EntityOperator.NOT_EQUAL, null)])
if (ratingReviews) {
- context.averageRating = ProductWorker.getAverageProductRating(product, reviews, productStoreId);
- context.numRatings = ratingReviews.size();
+ context.averageRating = ProductWorker.getAverageProductRating(product, reviews, productStoreId)
+ context.numRatings = ratingReviews.size()
}
}
// get the days to ship
// if order is purchase then don't calculate available inventory for product.
if (cart.isSalesOrder()) {
- facilityId = productStore.inventoryFacilityId;
+ facilityId = productStore.inventoryFacilityId
- resultOutput = runService('getInventoryAvailableByFacility', [productId : productId, facilityId : facilityId, useCache : false]);
- totalAvailableToPromise = resultOutput.availableToPromiseTotal;
+ resultOutput = runService('getInventoryAvailableByFacility', [productId : productId, facilityId : facilityId, useCache : false])
+ totalAvailableToPromise = resultOutput.availableToPromiseTotal
if (totalAvailableToPromise) {
- productFacility = from("ProductFacility").where("productId", productId, "facilityId", facilityId).cache(true).queryOne();
+ productFacility = from("ProductFacility").where("productId", productId, "facilityId", facilityId).cache(true).queryOne()
context.daysToShip = productFacility?.daysToShip
}
} else {
- supplierProduct = from("SupplierProduct").where("productId", productId).orderBy("-availableFromDate").cache(true).queryFirst();
+ supplierProduct = from("SupplierProduct").where("productId", productId).orderBy("-availableFromDate").cache(true).queryFirst()
if (supplierProduct?.standardLeadTimeDays) {
- standardLeadTimeDays = supplierProduct.standardLeadTimeDays;
- daysToShip = standardLeadTimeDays + 1;
- context.daysToShip = daysToShip;
+ standardLeadTimeDays = supplierProduct.standardLeadTimeDays
+ daysToShip = standardLeadTimeDays + 1
+ context.daysToShip = daysToShip
}
}
// get the product distinguishing features
- disFeatureMap = runService('getProductFeatures', [productId : productId, type : "DISTINGUISHING_FEAT"]);
- disFeatureList = disFeatureMap.productFeatures;
- context.disFeatureList = disFeatureList;
+ disFeatureMap = runService('getProductFeatures', [productId : productId, type : "DISTINGUISHING_FEAT"])
+ disFeatureList = disFeatureMap.productFeatures
+ context.disFeatureList = disFeatureList
// an example of getting features of a certain type to show
- sizeProductFeatureAndAppls = from("ProductFeatureAndAppl").where("productId", productId, "productFeatureTypeId", "SIZE").orderBy("sequenceNum", "defaultSequenceNum").queryList();
- context.sizeProductFeatureAndAppls = sizeProductFeatureAndAppls;
+ sizeProductFeatureAndAppls = from("ProductFeatureAndAppl").where("productId", productId, "productFeatureTypeId", "SIZE").orderBy("sequenceNum", "defaultSequenceNum").queryList()
+ context.sizeProductFeatureAndAppls = sizeProductFeatureAndAppls
// get product variant for Box/Case/Each
- productVariants = [];
- boolean isAlternativePacking = ProductWorker.isAlternativePacking(delegator, product.productId, null);
- mainProducts = [];
+ productVariants = []
+ boolean isAlternativePacking = ProductWorker.isAlternativePacking(delegator, product.productId, null)
+ mainProducts = []
if(isAlternativePacking){
- productVirtualVariants = from("ProductAssoc").where("productIdTo", product.productId , "productAssocTypeId", "ALTERNATIVE_PACKAGE").cache(true).queryList();
+ productVirtualVariants = from("ProductAssoc").where("productIdTo", product.productId , "productAssocTypeId", "ALTERNATIVE_PACKAGE").cache(true).queryList()
if(productVirtualVariants){
productVirtualVariants.each { virtualVariantKey ->
- mainProductMap = [:];
- mainProduct = virtualVariantKey.getRelatedOne("MainProduct", true);
- quantityUom = mainProduct.getRelatedOne("QuantityUom", true);
- mainProductMap.productId = mainProduct.productId;
- mainProductMap.piecesIncluded = mainProduct.piecesIncluded;
- mainProductMap.uomDesc = quantityUom.description;
- mainProducts.add(mainProductMap);
+ mainProductMap = [:]
+ mainProduct = virtualVariantKey.getRelatedOne("MainProduct", true)
+ quantityUom = mainProduct.getRelatedOne("QuantityUom", true)
+ mainProductMap.productId = mainProduct.productId
+ mainProductMap.piecesIncluded = mainProduct.piecesIncluded
+ mainProductMap.uomDesc = quantityUom.description
+ mainProducts.add(mainProductMap)
}
}
}
- context.mainProducts = mainProducts;
+ context.mainProducts = mainProducts
// Special Variant Code
if ("Y".equals(product.isVirtual)) {
if ("VV_FEATURETREE".equals(ProductWorker.getProductVirtualVariantMethod(delegator, productId))) {
- context.featureLists = ProductWorker.getSelectableProductFeaturesByTypesAndSeq(product);
+ context.featureLists = ProductWorker.getSelectableProductFeaturesByTypesAndSeq(product)
} else {
- featureMap = runService('getProductFeatureSet', [productId : productId]);
- featureSet = featureMap.featureSet;
+ featureMap = runService('getProductFeatureSet', [productId : productId])
+ featureSet = featureMap.featureSet
if (featureSet) {
//if order is purchase then don't calculate available inventory for product.
if (cart.isPurchaseOrder()) {
- variantTreeMap = runService('getProductVariantTree', [productId : productId, featureOrder : featureSet, checkInventory: false]);
+ variantTreeMap = runService('getProductVariantTree', [productId : productId, featureOrder : featureSet, checkInventory: false])
} else {
- variantTreeMap = runService('getProductVariantTree', [productId : productId, featureOrder : featureSet, productStoreId : productStoreId]);
+ variantTreeMap = runService('getProductVariantTree', [productId : productId, featureOrder : featureSet, productStoreId : productStoreId])
}
- variantTree = variantTreeMap.variantTree;
- imageMap = variantTreeMap.variantSample;
- virtualVariant = variantTreeMap.virtualVariant;
- context.virtualVariant = virtualVariant;
+ variantTree = variantTreeMap.variantTree
+ imageMap = variantTreeMap.variantSample
+ virtualVariant = variantTreeMap.virtualVariant
+ context.virtualVariant = virtualVariant
if (variantTree) {
- context.variantTree = variantTree;
- context.variantTreeSize = variantTree.size();
+ context.variantTree = variantTree
+ context.variantTreeSize = variantTree.size()
}
- unavailableVariants = variantTreeMap.unavailableVariants;
+ unavailableVariants = variantTreeMap.unavailableVariants
if (unavailableVariants) {
- context.unavailableVariants = unavailableVariants;
+ context.unavailableVariants = unavailableVariants
}
if (imageMap) {
- context.variantSample = imageMap;
- context.variantSampleKeys = imageMap.keySet();
- context.variantSampleSize = imageMap.size();
+ context.variantSample = imageMap
+ context.variantSampleKeys = imageMap.keySet()
+ context.variantSampleSize = imageMap.size()
}
- context.featureSet = featureSet;
+ context.featureSet = featureSet
if (variantTree) {
- featureOrder = new LinkedList(featureSet);
+ featureOrder = new LinkedList(featureSet)
featureOrder.each { featureKey ->
- featureValue = from("ProductFeatureType").where("productFeatureTypeId", featureKey).cache(true).queryOne();
- fValue = featureValue.get("description") ?: featureValue.productFeatureTypeId;
- featureTypes[featureKey] = fValue;
+ featureValue = from("ProductFeatureType").where("productFeatureTypeId", featureKey).cache(true).queryOne()
+ fValue = featureValue.get("description") ?: featureValue.productFeatureTypeId
+ featureTypes[featureKey] = fValue
}
}
- context.featureTypes = featureTypes;
- context.featureOrder = featureOrder;
+ context.featureTypes = featureTypes
+ context.featureOrder = featureOrder
if (featureOrder) {
- context.featureOrderFirst = featureOrder[0];
+ context.featureOrderFirst = featureOrder[0]
}
if (variantTree && imageMap) {
- jsBuf = new StringBuffer();
- jsBuf.append("<script language=\"JavaScript\" type=\"text/javascript\">");
- jsBuf.append("var DET = new Array(" + variantTree.size() + ");");
- jsBuf.append("var IMG = new Array(" + variantTree.size() + ");");
- jsBuf.append("var OPT = new Array(" + featureOrder.size() + ");");
- jsBuf.append("var VIR = new Array(" + virtualVariant.size() + ");");
- jsBuf.append("var detailImageUrl = null;");
+ jsBuf = new StringBuffer()
+ jsBuf.append("<script language=\"JavaScript\" type=\"text/javascript\">")
+ jsBuf.append("var DET = new Array(" + variantTree.size() + ");")
+ jsBuf.append("var IMG = new Array(" + variantTree.size() + ");")
+ jsBuf.append("var OPT = new Array(" + featureOrder.size() + ");")
+ jsBuf.append("var VIR = new Array(" + virtualVariant.size() + ");")
+ jsBuf.append("var detailImageUrl = null;")
featureOrder.eachWithIndex { feature, i ->
- jsBuf.append("OPT[" + i + "] = \"FT" + feature + "\";");
+ jsBuf.append("OPT[" + i + "] = \"FT" + feature + "\";")
}
virtualVariant.eachWithIndex { variant, i ->
- jsBuf.append("VIR[" + i + "] = \"" + variant + "\";");
+ jsBuf.append("VIR[" + i + "] = \"" + variant + "\";")
}
// build the top level
- topLevelName = featureOrder[0];
- jsBuf.append("function list" + topLevelName + "() {");
- jsBuf.append("document.forms[\"addform\"].elements[\"FT" + topLevelName + "\"].options.length = 1;");
- jsBuf.append("document.forms[\"addform\"].elements[\"FT" + topLevelName + "\"].options[0] = new Option(\"" + featureTypes[topLevelName] + "\",\"\",true,true);");
+ topLevelName = featureOrder[0]
+ jsBuf.append("function list" + topLevelName + "() {")
+ jsBuf.append("document.forms[\"addform\"].elements[\"FT" + topLevelName + "\"].options.length = 1;")
+ jsBuf.append("document.forms[\"addform\"].elements[\"FT" + topLevelName + "\"].options[0] = new Option(\"" + featureTypes[topLevelName] + "\",\"\",true,true);")
if (variantTree) {
featureOrder.each { featureKey ->
- jsBuf.append("document.forms[\"addform\"].elements[\"FT" + featureKey + "\"].options.length = 1;");
+ jsBuf.append("document.forms[\"addform\"].elements[\"FT" + featureKey + "\"].options.length = 1;")
}
- firstDetailImage = null;
- firstLargeImage = null;
- counter = 0;
+ firstDetailImage = null
+ firstLargeImage = null
+ counter = 0
variantTree.each { key, value ->
- opt = null;
+ opt = null
if (featureOrder.size() == 1) {
- opt = value.iterator().next();
+ opt = value.iterator().next()
} else {
- opt = counter as String;
+ opt = counter as String
}
// create the variant content wrapper
- contentWrapper = new ProductContentWrapper(imageMap[key], request);
+ contentWrapper = new ProductContentWrapper(imageMap[key], request)
// initial image paths
- detailImage = contentWrapper.get("DETAIL_IMAGE_URL", "url") ?: productContentWrapper.get("DETAIL_IMAGE_URL", "url");
- largeImage = contentWrapper.get("LARGE_IMAGE_URL", "url") ?: productContentWrapper.get("LARGE_IMAGE_URL", "url");
+ detailImage = contentWrapper.get("DETAIL_IMAGE_URL", "url") ?: productContentWrapper.get("DETAIL_IMAGE_URL", "url")
+ largeImage = contentWrapper.get("LARGE_IMAGE_URL", "url") ?: productContentWrapper.get("LARGE_IMAGE_URL", "url")
// full image URLs
- detailImageUrl = null;
- largeImageUrl = null;
+ detailImageUrl = null
+ largeImageUrl = null
// append the content prefix
if (detailImage) {
- detailImageUrl = (ContentUrlTag.getContentPrefix(request) + detailImage).toString();
+ detailImageUrl = (ContentUrlTag.getContentPrefix(request) + detailImage).toString()
}
if (largeImage) {
- largeImageUrl = ContentUrlTag.getContentPrefix(request) + largeImage;
+ largeImageUrl = ContentUrlTag.getContentPrefix(request) + largeImage
}
- jsBuf.append("document.forms[\"addform\"].elements[\"FT" + topLevelName + "\"].options[" + (counter+1) + "] = new Option(\"" + key + "\",\"" + opt + "\");");
- jsBuf.append("DET[" + counter + "] = \"" + detailImageUrl +"\";");
- jsBuf.append("IMG[" + counter + "] = \"" + largeImageUrl +"\";");
+ jsBuf.append("document.forms[\"addform\"].elements[\"FT" + topLevelName + "\"].options[" + (counter+1) + "] = new Option(\"" + key + "\",\"" + opt + "\");")
+ jsBuf.append("DET[" + counter + "] = \"" + detailImageUrl +"\";")
+ jsBuf.append("IMG[" + counter + "] = \"" + largeImageUrl +"\";")
if (!firstDetailImage) {
- firstDetailImage = detailImageUrl;
+ firstDetailImage = detailImageUrl
}
if (!firstLargeImage) {
- firstLargeImage = largeImage;
+ firstLargeImage = largeImage
}
- counter++;
+ counter++
}
- context.firstDetailImage = firstDetailImage;
- context.firstLargeImage = firstLargeImage;
+ context.firstDetailImage = firstDetailImage
+ context.firstLargeImage = firstLargeImage
}
- jsBuf.append("}");
+ jsBuf.append("}")
// build dynamic lists
if (variantTree) {
variantTree.values().eachWithIndex { varTree, topLevelKeysCt ->
- cnt = "" + topLevelKeysCt;
+ cnt = "" + topLevelKeysCt
if (varTree instanceof Map) {
- jsBuf.append(buildNext(varTree, featureOrder, featureOrder[1], cnt, featureTypes));
+ jsBuf.append(buildNext(varTree, featureOrder, featureOrder[1], cnt, featureTypes))
}
}
}
// make a list of variant sku with requireAmount
- variantsRes = runService('getAssociatedProducts', [productId : productId, type : "PRODUCT_VARIANT", checkViewAllow : true, prodCatalogId : currentCatalogId]);
- variants = variantsRes.assocProducts;
- variantPriceList = [];
+ variantsRes = runService('getAssociatedProducts', [productId : productId, type : "PRODUCT_VARIANT", checkViewAllow : true, prodCatalogId : currentCatalogId])
+ variants = variantsRes.assocProducts
+ variantPriceList = []
if (variants) {
- amt = new StringBuffer();
- amt.append("function checkAmtReq(sku) { ");
+ amt = new StringBuffer()
+ amt.append("function checkAmtReq(sku) { ")
// Create the javascript to return the price for each variant
- variantPriceJS = new StringBuffer();
- variantPriceJS.append("function getVariantPrice(sku) { ");
+ variantPriceJS = new StringBuffer()
+ variantPriceJS.append("function getVariantPrice(sku) { ")
// Format to apply the currency code to the variant price in the javascript
if (productStore) {
- localeString = productStore.defaultLocaleString;
+ localeString = productStore.defaultLocaleString
if (localeString) {
- locale = UtilMisc.parseLocale(localeString);
+ locale = UtilMisc.parseLocale(localeString)
}
}
variants.each { variantAssoc ->
- variant = variantAssoc.getRelatedOne("AssocProduct", false);
+ variant = variantAssoc.getRelatedOne("AssocProduct", false)
// Get the price for each variant. Reuse the priceContext already setup for virtual product above and replace the product
- priceContext.product = variant;
+ priceContext.product = variant
if (cart.isSalesOrder()) {
// sales order: run the "calculateProductPrice" service
- variantPriceMap = runService('calculateProductPrice', priceContext);
- BigDecimal calculatedPrice = (BigDecimal)variantPriceMap.get("price");
+ variantPriceMap = runService('calculateProductPrice', priceContext)
+ BigDecimal calculatedPrice = (BigDecimal)variantPriceMap.get("price")
// Get the minimum quantity for variants if MINIMUM_ORDER_PRICE is set for variants.
- variantPriceMap.put("minimumQuantity", ShoppingCart.getMinimumOrderQuantity(delegator, calculatedPrice, variant.get("productId")));
- Iterator treeMapIter = variantTree.entrySet().iterator();
+ variantPriceMap.put("minimumQuantity", ShoppingCart.getMinimumOrderQuantity(delegator, calculatedPrice, variant.get("productId")))
+ Iterator treeMapIter = variantTree.entrySet().iterator()
while (treeMapIter.hasNext()) {
- Map.Entry entry = treeMapIter.next();
+ Map.Entry entry = treeMapIter.next()
if (entry.getValue() instanceof Map) {
- Iterator entryIter = entry.getValue().entrySet().iterator();
+ Iterator entryIter = entry.getValue().entrySet().iterator()
while (entryIter.hasNext()) {
- Map.Entry innerentry = entryIter.next();
+ Map.Entry innerentry = entryIter.next()
if (variant.get("productId").equals(innerentry.getValue().get(0))) {
- variantPriceMap.put("variantName", innerentry.getKey());
- variantPriceMap.put("secondVariantName", entry.getKey());
- break;
+ variantPriceMap.put("variantName", innerentry.getKey())
+ variantPriceMap.put("secondVariantName", entry.getKey())
+ break
}
}
} else if (UtilValidate.isNotEmpty(entry.getValue())) {
if (variant.get("productId").equals(entry.getValue().get(0))) {
- variantPriceMap.put("variantName", entry.getKey());
- break;
+ variantPriceMap.put("variantName", entry.getKey())
+ break
}
}
}
- variantPriceList.add(variantPriceMap);
+ variantPriceList.add(variantPriceMap)
} else {
- variantPriceMap = runService('calculatePurchasePrice', priceContext);
+ variantPriceMap = runService('calculatePurchasePrice', priceContext)
}
- amt.append(" if (sku == \"" + variant.productId + "\") return \"" + (variant.requireAmount ?: "N") + "\"; ");
+ amt.append(" if (sku == \"" + variant.productId + "\") return \"" + (variant.requireAmount ?: "N") + "\"; ")
if (variantPriceMap && variantPriceMap.basePrice) {
- variantPriceJS.append(" if (sku == \"" + variant.productId + "\") return \"" + UtilFormatOut.formatCurrency(variantPriceMap.basePrice, currencyUomId, locale, 10) + "\"; ");
+ variantPriceJS.append(" if (sku == \"" + variant.productId + "\") return \"" + UtilFormatOut.formatCurrency(variantPriceMap.basePrice, currencyUomId, locale, 10) + "\"; ")
}
// make a list of virtual variants sku with requireAmount
- virtualVariantsRes = runService('getAssociatedProducts', [productIdTo : variant.productId, type : "ALTERNATIVE_PACKAGE", checkViewAllow : true, prodCatalogId : currentCatalogId]);
- virtualVariants = virtualVariantsRes.assocProducts;
+ virtualVariantsRes = runService('getAssociatedProducts', [productIdTo : variant.productId, type : "ALTERNATIVE_PACKAGE", checkViewAllow : true, prodCatalogId : currentCatalogId])
+ virtualVariants = virtualVariantsRes.assocProducts
if(virtualVariants){
virtualVariants.each { virtualAssoc ->
- virtual = virtualAssoc.getRelatedOne("MainProduct", false);
+ virtual = virtualAssoc.getRelatedOne("MainProduct", false)
// Get price from a virtual product
- priceContext.product = virtual;
+ priceContext.product = virtual
if (cart.isSalesOrder()) {
// sales order: run the "calculateProductPrice" service
- virtualPriceMap = runService('calculateProductPrice', priceContext);
- BigDecimal calculatedPrice = (BigDecimal)virtualPriceMap.get("price");
+ virtualPriceMap = runService('calculateProductPrice', priceContext)
+ BigDecimal calculatedPrice = (BigDecimal)virtualPriceMap.get("price")
// Get the minimum quantity for variants if MINIMUM_ORDER_PRICE is set for variants.
- virtualPriceMap.put("minimumQuantity", ShoppingCart.getMinimumOrderQuantity(delegator, calculatedPrice, virtual.get("productId")));
- Iterator treeMapIter = variantTree.entrySet().iterator();
+ virtualPriceMap.put("minimumQuantity", ShoppingCart.getMinimumOrderQuantity(delegator, calculatedPrice, virtual.get("productId")))
+ Iterator treeMapIter = variantTree.entrySet().iterator()
while (treeMapIter.hasNext()) {
- Map.Entry entry = treeMapIter.next();
+ Map.Entry entry = treeMapIter.next()
if (entry.getValue() instanceof Map) {
- Iterator entryIter = entry.getValue().entrySet().iterator();
+ Iterator entryIter = entry.getValue().entrySet().iterator()
while (entryIter.hasNext()) {
- Map.Entry innerentry = entryIter.next();
+ Map.Entry innerentry = entryIter.next()
if (virtual.get("productId").equals(innerentry.getValue().get(0))) {
- virtualPriceMap.put("variantName", innerentry.getKey());
- virtualPriceMap.put("secondVariantName", entry.getKey());
- break;
+ virtualPriceMap.put("variantName", innerentry.getKey())
+ virtualPriceMap.put("secondVariantName", entry.getKey())
+ break
}
}
} else if (UtilValidate.isNotEmpty(entry.getValue())) {
if (virtual.get("productId").equals(entry.getValue().get(0))) {
- virtualPriceMap.put("variantName", entry.getKey());
- break;
+ virtualPriceMap.put("variantName", entry.getKey())
+ break
}
}
}
- variantPriceList.add(virtualPriceMap);
- variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + UtilFormatOut.formatCurrency(variantPriceMap.basePrice, currencyUomId, locale, 10) + "\"; ");
+ variantPriceList.add(virtualPriceMap)
+ variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + UtilFormatOut.formatCurrency(variantPriceMap.basePrice, currencyUomId, locale, 10) + "\"; ")
} else {
- virtualPriceMap = runService('calculatePurchasePrice', priceContext);
- variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + UtilFormatOut.formatCurrency(variantPriceMap.price, currencyUomId, locale, 10) + "\"; ");
+ virtualPriceMap = runService('calculatePurchasePrice', priceContext)
+ variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + UtilFormatOut.formatCurrency(variantPriceMap.price, currencyUomId, locale, 10) + "\"; ")
}
}
}
}
- amt.append(" } ");
- variantPriceJS.append(" } ");
+ amt.append(" } ")
+ variantPriceJS.append(" } ")
}
- context.variantPriceList = variantPriceList;
- jsBuf.append(amt.toString());
- jsBuf.append(variantPriceJS.toString());
- jsBuf.append("</script>");
+ context.variantPriceList = variantPriceList
+ jsBuf.append(amt.toString())
+ jsBuf.append(variantPriceJS.toString())
+ jsBuf.append("</script>")
- context.virtualJavaScript = jsBuf;
+ context.virtualJavaScript = jsBuf
}
}
}
} else {
- context.minimumQuantity= ShoppingCart.getMinimumOrderQuantity(delegator, priceMap.price, productId);
+ context.minimumQuantity= ShoppingCart.getMinimumOrderQuantity(delegator, priceMap.price, productId)
if(isAlternativePacking){
// get alternative product price when product doesn't have any feature
- jsBuf = new StringBuffer();
- jsBuf.append("<script language=\"JavaScript\" type=\"text/javascript\">");
+ jsBuf = new StringBuffer()
+ jsBuf.append("<script language=\"JavaScript\" type=\"text/javascript\">")
// make a list of variant sku with requireAmount
- virtualVariantsRes = runService('getAssociatedProducts', [productIdTo : productId, type : "ALTERNATIVE_PACKAGE", checkViewAllow : true, prodCatalogId : categoryId]);
- virtualVariants = virtualVariantsRes.assocProducts;
+ virtualVariantsRes = runService('getAssociatedProducts', [productIdTo : productId, type : "ALTERNATIVE_PACKAGE", checkViewAllow : true, prodCatalogId : categoryId])
+ virtualVariants = virtualVariantsRes.assocProducts
// Format to apply the currency code to the variant price in the javascript
if (productStore) {
- localeString = productStore.defaultLocaleString;
+ localeString = productStore.defaultLocaleString
if (localeString) {
- locale = UtilMisc.parseLocale(localeString);
+ locale = UtilMisc.parseLocale(localeString)
}
}
- virtualVariantPriceList = [];
+ virtualVariantPriceList = []
if(virtualVariants){
- amt = new StringBuffer();
+ amt = new StringBuffer()
// Create the javascript to return the price for each variant
- variantPriceJS = new StringBuffer();
- variantPriceJS.append("function getVariantPrice(sku) { ");
+ variantPriceJS = new StringBuffer()
+ variantPriceJS.append("function getVariantPrice(sku) { ")
virtualVariants.each { virtualAssoc ->
- virtual = virtualAssoc.getRelatedOne("MainProduct", false);
+ virtual = virtualAssoc.getRelatedOne("MainProduct", false)
// Get price from a virtual product
- priceContext.product = virtual;
+ priceContext.product = virtual
if (cart.isSalesOrder()) {
// sales order: run the "calculateProductPrice" service
- virtualPriceMap = runService('calculateProductPrice', priceContext);
- BigDecimal calculatedPrice = (BigDecimal)virtualPriceMap.get("price");
+ virtualPriceMap = runService('calculateProductPrice', priceContext)
+ BigDecimal calculatedPrice = (BigDecimal)virtualPriceMap.get("price")
// Get the minimum quantity for variants if MINIMUM_ORDER_PRICE is set for variants.
- virtualVariantPriceList.add(virtualPriceMap);
- variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + UtilFormatOut.formatCurrency(virtualPriceMap.basePrice, currencyUomId, locale, 10) + "\"; ");
+ virtualVariantPriceList.add(virtualPriceMap)
+ variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + UtilFormatOut.formatCurrency(virtualPriceMap.basePrice, currencyUomId, locale, 10) + "\"; ")
} else {
- virtualPriceMap = runService('calculatePurchasePrice', priceContext);
- variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + UtilFormatOut.formatCurrency(virtualPriceMap.price, currencyUomId, locale, 10) + "\"; ");
+ virtualPriceMap = runService('calculatePurchasePrice', priceContext)
+ variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + UtilFormatOut.formatCurrency(virtualPriceMap.price, currencyUomId, locale, 10) + "\"; ")
}
}
- variantPriceJS.append(" } ");
+ variantPriceJS.append(" } ")
- context.virtualVariantPriceList = virtualVariantPriceList;
- jsBuf.append(amt.toString());
- jsBuf.append(variantPriceJS.toString());
- jsBuf.append("</script>");
- context.virtualVariantJavaScript = jsBuf;
+ context.virtualVariantPriceList = virtualVariantPriceList
+ jsBuf.append(amt.toString())
+ jsBuf.append(variantPriceJS.toString())
+ jsBuf.append("</script>")
+ context.virtualVariantJavaScript = jsBuf
}
}
}
- availableInventory = 0.0;
+ availableInventory = 0.0
// if the product is a MARKETING_PKG_AUTO/PICK, then also get the quantity which can be produced from components
if (isMarketingPackage) {
- resultOutput = runService('getMktgPackagesAvailable', [productId : productId]);
- availableInventory = resultOutput.availableToPromiseTotal;
+ resultOutput = runService('getMktgPackagesAvailable', [productId : productId])
+ availableInventory = resultOutput.availableToPromiseTotal
} else {
//get last inventory count from product facility for the product
- facilities = from("ProductFacility").where("productId", product.productId).queryList();
+ facilities = from("ProductFacility").where("productId", product.productId).queryList()
if(facilities) {
facilities.each { facility ->
- lastInventoryCount = facility.lastInventoryCount;
+ lastInventoryCount = facility.lastInventoryCount
if (lastInventoryCount != null) {
- availableInventory += lastInventoryCount;
+ availableInventory += lastInventoryCount
}
}
}
}
- context.availableInventory = availableInventory;
+ context.availableInventory = availableInventory
// get product associations
- alsoBoughtProducts = runService('getAssociatedProducts', [productId : productId, type : "ALSO_BOUGHT", checkViewAllow : true, prodCatalogId : currentCatalogId, bidirectional : false, sortDescending : true]);
- context.alsoBoughtProducts = alsoBoughtProducts.assocProducts;
+ alsoBoughtProducts = runService('getAssociatedProducts', [productId : productId, type : "ALSO_BOUGHT", checkViewAllow : true, prodCatalogId : currentCatalogId, bidirectional : false, sortDescending : true])
+ context.alsoBoughtProducts = alsoBoughtProducts.assocProducts
- obsoleteProducts = runService('getAssociatedProducts', [productId : productId, type : "PRODUCT_OBSOLESCENCE", checkViewAllow : true, prodCatalogId : currentCatalogId]);
- context.obsoleteProducts = obsoleteProducts.assocProducts;
+ obsoleteProducts = runService('getAssociatedProducts', [productId : productId, type : "PRODUCT_OBSOLESCENCE", checkViewAllow : true, prodCatalogId : currentCatalogId])
+ context.obsoleteProducts = obsoleteProducts.assocProducts
- crossSellProducts = runService('getAssociatedProducts', [productId : productId, type : "PRODUCT_COMPLEMENT", checkViewAllow : true, prodCatalogId : currentCatalogId]);
- context.crossSellProducts = crossSellProducts.assocProducts;
+ crossSellProducts = runService('getAssociatedProducts', [productId : productId, type : "PRODUCT_COMPLEMENT", checkViewAllow : true, prodCatalogId : currentCatalogId])
+ context.crossSellProducts = crossSellProducts.assocProducts
- upSellProducts = runService('getAssociatedProducts', [productId : productId, type : "PRODUCT_UPGRADE", checkViewAllow : true, prodCatalogId : currentCatalogId]);
- context.upSellProducts = upSellProducts.assocProducts;
+ upSellProducts = runService('getAssociatedProducts', [productId : productId, type : "PRODUCT_UPGRADE", checkViewAllow : true, prodCatalogId : currentCatalogId])
+ context.upSellProducts = upSellProducts.assocProducts
- obsolenscenseProducts = runService('getAssociatedProducts', [productIdTo : productId, type : "PRODUCT_OBSOLESCENCE", checkViewAllow : true, prodCatalogId : currentCatalogId]);
- context.obsolenscenseProducts = obsolenscenseProducts.assocProducts;
+ obsolenscenseProducts = runService('getAssociatedProducts', [productIdTo : productId, type : "PRODUCT_OBSOLESCENCE", checkViewAllow : true, prodCatalogId : currentCatalogId])
+ context.obsolenscenseProducts = obsolenscenseProducts.assocProducts
- accessoryProducts = runService('getAssociatedProducts', [productId : productId, type : "PRODUCT_ACCESSORY", checkViewAllow : true, prodCatalogId : currentCatalogId]);
- context.accessoryProducts = accessoryProducts.assocProducts;
+ accessoryProducts = runService('getAssociatedProducts', [productId : productId, type : "PRODUCT_ACCESSORY", checkViewAllow : true, prodCatalogId : currentCatalogId])
+ context.accessoryProducts = accessoryProducts.assocProducts
// get the DIGITAL_DOWNLOAD related Content records to show the contentName/description
- downloadProductContentAndInfoList = from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", "DIGITAL_DOWNLOAD").cache(true).queryList();
- context.downloadProductContentAndInfoList = downloadProductContentAndInfoList;
+ downloadProductContentAndInfoList = from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", "DIGITAL_DOWNLOAD").cache(true).queryList()
+ context.downloadProductContentAndInfoList = downloadProductContentAndInfoList
// not the best to save info in an action, but this is probably the best place to count a view; it is done async
- dispatcher.runAsync("countProductView", [productId : productId, weight : new Long(1)], false);
+ dispatcher.runAsync("countProductView", [productId : productId, weight : new Long(1)], false)
//get product image from image management
- productImageList = [];
- productContentAndInfoImageManamentList = from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", "IMAGE", "statusId", "IM_APPROVED", "drIsPublic", "Y").orderBy("sequenceNum").queryList();
+ productImageList = []
+ productContentAndInfoImageManamentList = from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", "IMAGE", "statusId", "IM_APPROVED", "drIsPublic", "Y").orderBy("sequenceNum").queryList()
if(productContentAndInfoImageManamentList) {
productContentAndInfoImageManamentList.each { productContentAndInfoImageManament ->
- contentAssocThumb = from("ContentAssoc").where("contentId", productContentAndInfoImageManament.contentId, "contentAssocTypeId", "IMAGE_THUMBNAIL").queryFirst();
+ contentAssocThumb = from("ContentAssoc").where("contentId", productContentAndInfoImageManament.contentId, "contentAssocTypeId", "IMAGE_THUMBNAIL").queryFirst()
if(contentAssocThumb) {
- imageContentThumb = from("Content").where("contentId", contentAssocThumb.contentIdTo).queryOne();
+ imageContentThumb = from("Content").where("contentId", contentAssocThumb.contentIdTo).queryOne()
if(imageContentThumb) {
- productImageThumb = from("ContentDataResourceView").where("contentId", imageContentThumb.contentId, "drDataResourceId", imageContentThumb.dataResourceId).queryOne();
- productImageMap = [:];
- productImageMap.productImageThumb = productImageThumb.drObjectInfo;
- productImageMap.productImage = productContentAndInfoImageManament.drObjectInfo;
- productImageList.add(productImageMap);
+ productImageThumb = from("ContentDataResourceView").where("contentId", imageContentThumb.contentId, "drDataResourceId", imageContentThumb.dataResourceId).queryOne()
+ productImageMap = [:]
+ productImageMap.productImageThumb = productImageThumb.drObjectInfo
+ productImageMap.productImage = productContentAndInfoImageManament.drObjectInfo
+ productImageList.add(productImageMap)
}
}
}
- context.productImageList = productImageList;
+ context.productImageList = productImageList
}
// get reservation start date for rental product
if("ASSET_USAGE".equals(productTypeId) || "ASSET_USAGE_OUT_IN".equals(productTypeId)){
- context.startDate = UtilDateTime.addDaysToTimestamp(UtilDateTime.nowTimestamp(), 1).toString().substring(0,10); // should be tomorrow.
+ context.startDate = UtilDateTime.addDaysToTimestamp(UtilDateTime.nowTimestamp(), 1).toString().substring(0,10) // should be tomorrow.
}
// get product tags
- productKeywords = from("ProductKeyword").where("productId": productId, "keywordTypeId" : "KWT_TAG", "statusId" : "KW_APPROVED").queryList();
- keywordMap = [:];
+ productKeywords = from("ProductKeyword").where("productId": productId, "keywordTypeId" : "KWT_TAG", "statusId" : "KW_APPROVED").queryList()
+ keywordMap = [:]
if (productKeywords) {
for (productKeyword in productKeywords) {
- productKeyWordCount = from("ProductKeyword").where("keyword", productKeyword.keyword, "keywordTypeId", "KWT_TAG", "statusId", "KW_APPROVED").queryCount();
- keywordMap.put(productKeyword.keyword,productKeyWordCount);
+ productKeyWordCount = from("ProductKeyword").where("keyword", productKeyword.keyword, "keywordTypeId", "KWT_TAG", "statusId", "KW_APPROVED").queryCount()
+ keywordMap.put(productKeyword.keyword,productKeyWordCount)
}
- context.productTags = keywordMap;
+ context.productTags = keywordMap
}
}
Modified: ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ProductSummary.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ProductSummary.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ProductSummary.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ProductSummary.groovy Wed Nov 2 19:09:13 2016
@@ -22,214 +22,214 @@
* should not contain order component's specific code.
*/
-import org.apache.ofbiz.base.util.*;
-import org.apache.ofbiz.entity.*;
-import org.apache.ofbiz.entity.util.EntityQuery;
-import org.apache.ofbiz.service.*;
-import org.apache.ofbiz.product.product.ProductContentWrapper;
-import org.apache.ofbiz.product.config.ProductConfigWorker;
-import org.apache.ofbiz.product.catalog.*;
-import org.apache.ofbiz.product.store.*;
-import org.apache.ofbiz.order.shoppingcart.*;
-import org.apache.ofbiz.product.product.ProductWorker;
+import org.apache.ofbiz.base.util.*
+import org.apache.ofbiz.entity.*
+import org.apache.ofbiz.entity.util.EntityQuery
+import org.apache.ofbiz.service.*
+import org.apache.ofbiz.product.product.ProductContentWrapper
+import org.apache.ofbiz.product.config.ProductConfigWorker
+import org.apache.ofbiz.product.catalog.*
+import org.apache.ofbiz.product.store.*
+import org.apache.ofbiz.order.shoppingcart.*
+import org.apache.ofbiz.product.product.ProductWorker
import org.apache.ofbiz.webapp.website.WebSiteWorker
-import java.text.NumberFormat;
+import java.text.NumberFormat
//either optProduct, optProductId or productId must be specified
-product = request.getAttribute("optProduct");
-optProductId = request.getAttribute("optProductId");
-productId = product?.productId ?: optProductId ?: request.getAttribute("productId");
-
-webSiteId = WebSiteWorker.getWebSiteId(request);
-catalogId = CatalogWorker.getCurrentCatalogId(request);
-cart = ShoppingCartEvents.getCartObject(request);
-productStore = null;
-productStoreId = null;
-facilityId = null;
+product = request.getAttribute("optProduct")
+optProductId = request.getAttribute("optProductId")
+productId = product?.productId ?: optProductId ?: request.getAttribute("productId")
+
+webSiteId = WebSiteWorker.getWebSiteId(request)
+catalogId = CatalogWorker.getCurrentCatalogId(request)
+cart = ShoppingCartEvents.getCartObject(request)
+productStore = null
+productStoreId = null
+facilityId = null
if (cart.isSalesOrder()) {
- productStore = ProductStoreWorker.getProductStore(request);
- productStoreId = productStore.productStoreId;
- context.productStoreId = productStoreId;
- facilityId = productStore.inventoryFacilityId;
+ productStore = ProductStoreWorker.getProductStore(request)
+ productStoreId = productStore.productStoreId
+ context.productStoreId = productStoreId
+ facilityId = productStore.inventoryFacilityId
}
if (!facilityId) {
- productStoreFacility = EntityQuery.use(delegator).select("facilityId").from("ProductStoreFacility").where("productStoreId", productStoreId).queryFirst();
+ productStoreFacility = EntityQuery.use(delegator).select("facilityId").from("ProductStoreFacility").where("productStoreId", productStoreId).queryFirst()
if (productStoreFacility) {
- facilityId = productStoreFacility.facilityId;
+ facilityId = productStoreFacility.facilityId
}
}
-autoUserLogin = session.getAttribute("autoUserLogin");
-userLogin = session.getAttribute("userLogin");
+autoUserLogin = session.getAttribute("autoUserLogin")
+userLogin = session.getAttribute("userLogin")
-context.remove("daysToShip");
-context.remove("averageRating");
-context.remove("numRatings");
-context.remove("totalPrice");
+context.remove("daysToShip")
+context.remove("averageRating")
+context.remove("numRatings")
+context.remove("totalPrice")
// get the product entity
if (!product && productId) {
- product = from("Product").where("productId", productId).cache(true).queryOne();
+ product = from("Product").where("productId", productId).cache(true).queryOne()
}
if (product) {
//if order is purchase then don't calculate available inventory for product.
if (cart.isSalesOrder()) {
- resultOutput = runService('getInventoryAvailableByFacility', [productId : product.productId, facilityId : facilityId, useCache : true]);
- totalAvailableToPromise = resultOutput.availableToPromiseTotal;
+ resultOutput = runService('getInventoryAvailableByFacility', [productId : product.productId, facilityId : facilityId, useCache : true])
+ totalAvailableToPromise = resultOutput.availableToPromiseTotal
if (totalAvailableToPromise && totalAvailableToPromise.doubleValue() > 0) {
- productFacility = from("ProductFacility").where("productId", product.productId, "facilityId", facilityId).cache(true).queryOne();
+ productFacility = from("ProductFacility").where("productId", product.productId, "facilityId", facilityId).cache(true).queryOne()
if (productFacility?.daysToShip != null) {
- context.daysToShip = productFacility.daysToShip;
+ context.daysToShip = productFacility.daysToShip
}
}
} else {
- supplierProduct = from("SupplierProduct").where("productId", product.productId).orderBy("-availableFromDate").cache(true).queryFirst();
+ supplierProduct = from("SupplierProduct").where("productId", product.productId).orderBy("-availableFromDate").cache(true).queryFirst()
if (supplierProduct?.standardLeadTimeDays != null) {
- standardLeadTimeDays = supplierProduct.standardLeadTimeDays;
- daysToShip = standardLeadTimeDays + 1;
- context.daysToShip = daysToShip;
+ standardLeadTimeDays = supplierProduct.standardLeadTimeDays
+ daysToShip = standardLeadTimeDays + 1
+ context.daysToShip = daysToShip
}
}
// make the productContentWrapper
- productContentWrapper = new ProductContentWrapper(product, request);
- context.productContentWrapper = productContentWrapper;
+ productContentWrapper = new ProductContentWrapper(product, request)
+ context.productContentWrapper = productContentWrapper
}
-categoryId = null;
-reviews = null;
+categoryId = null
+reviews = null
if (product) {
- categoryId = parameters.category_id ?: request.getAttribute("productCategoryId");
+ categoryId = parameters.category_id ?: request.getAttribute("productCategoryId")
// get the product price
if (cart.isSalesOrder()) {
// sales order: run the "calculateProductPrice" service
priceContext = [product : product, currencyUomId : cart.getCurrency(),
- autoUserLogin : autoUserLogin, userLogin : userLogin];
- priceContext.webSiteId = webSiteId;
- priceContext.prodCatalogId = catalogId;
- priceContext.productStoreId = productStoreId;
- priceContext.agreementId = cart.getAgreementId();
- priceContext.partyId = cart.getPartyId(); // IMPORTANT: otherwise it'll be calculating prices using the logged in user which could be a CSR instead of the customer
- priceContext.checkIncludeVat = "Y";
- priceMap = runService('calculateProductPrice', priceContext);
+ autoUserLogin : autoUserLogin, userLogin : userLogin]
+ priceContext.webSiteId = webSiteId
+ priceContext.prodCatalogId = catalogId
+ priceContext.productStoreId = productStoreId
+ priceContext.agreementId = cart.getAgreementId()
+ priceContext.partyId = cart.getPartyId() // IMPORTANT: otherwise it'll be calculating prices using the logged in user which could be a CSR instead of the customer
+ priceContext.checkIncludeVat = "Y"
+ priceMap = runService('calculateProductPrice', priceContext)
- context.price = priceMap;
+ context.price = priceMap
} else {
// purchase order: run the "calculatePurchasePrice" service
priceContext = [product : product, currencyUomId : cart.getCurrency(),
- partyId : cart.getPartyId(), userLogin : userLogin];
- priceMap = runService('calculatePurchasePrice', priceContext);
+ partyId : cart.getPartyId(), userLogin : userLogin]
+ priceMap = runService('calculatePurchasePrice', priceContext)
- context.price = priceMap;
+ context.price = priceMap
}
// get aggregated product totalPrice
if ("AGGREGATED".equals(product.productTypeId)||"AGGREGATED_SERVICE".equals(product.productTypeId)) {
- configWrapper = ProductConfigWorker.getProductConfigWrapper(productId, cart.getCurrency(), request);
+ configWrapper = ProductConfigWorker.getProductConfigWrapper(productId, cart.getCurrency(), request)
if (configWrapper) {
- configWrapper.setDefaultConfig();
- context.totalPrice = configWrapper.getTotalPrice();
+ configWrapper.setDefaultConfig()
+ context.totalPrice = configWrapper.getTotalPrice()
}
}
// get the product review(s)
- reviews = product.getRelated("ProductReview", null, ["-postedDateTime"], true);
+ reviews = product.getRelated("ProductReview", null, ["-postedDateTime"], true)
// get product variant for Box/Case/Each
- productVariants = [];
- boolean isAlternativePacking = ProductWorker.isAlternativePacking(delegator, product.productId, null);
- mainProducts = [];
+ productVariants = []
+ boolean isAlternativePacking = ProductWorker.isAlternativePacking(delegator, product.productId, null)
+ mainProducts = []
if(isAlternativePacking){
- productVirtualVariants = from("ProductAssoc").where("productIdTo", product.productId , "productAssocTypeId", "ALTERNATIVE_PACKAGE").cache(true).queryList();
+ productVirtualVariants = from("ProductAssoc").where("productIdTo", product.productId , "productAssocTypeId", "ALTERNATIVE_PACKAGE").cache(true).queryList()
if(productVirtualVariants){
productVirtualVariants.each { virtualVariantKey ->
- mainProductMap = [:];
- mainProduct = virtualVariantKey.getRelatedOne("MainProduct", true);
- quantityUom = mainProduct.getRelatedOne("QuantityUom", true);
- mainProductMap.productId = mainProduct.productId;
- mainProductMap.piecesIncluded = mainProduct.piecesIncluded;
- mainProductMap.uomDesc = quantityUom.description;
- mainProducts.add(mainProductMap);
+ mainProductMap = [:]
+ mainProduct = virtualVariantKey.getRelatedOne("MainProduct", true)
+ quantityUom = mainProduct.getRelatedOne("QuantityUom", true)
+ mainProductMap.productId = mainProduct.productId
+ mainProductMap.piecesIncluded = mainProduct.piecesIncluded
+ mainProductMap.uomDesc = quantityUom.description
+ mainProducts.add(mainProductMap)
}
}
// get alternative product price when product doesn't have any feature
- jsBuf = new StringBuffer();
- jsBuf.append("<script language=\"JavaScript\" type=\"text/javascript\">");
+ jsBuf = new StringBuffer()
+ jsBuf.append("<script language=\"JavaScript\" type=\"text/javascript\">")
// make a list of variant sku with requireAmount
- virtualVariantsRes = runService('getAssociatedProducts', [productIdTo : productId, type : "ALTERNATIVE_PACKAGE", checkViewAllow : true, prodCatalogId : categoryId]);
- virtualVariants = virtualVariantsRes.assocProducts;
+ virtualVariantsRes = runService('getAssociatedProducts', [productIdTo : productId, type : "ALTERNATIVE_PACKAGE", checkViewAllow : true, prodCatalogId : categoryId])
+ virtualVariants = virtualVariantsRes.assocProducts
// Format to apply the currency code to the variant price in the javascript
if (productStore) {
- localeString = productStore.defaultLocaleString;
+ localeString = productStore.defaultLocaleString
if (localeString) {
- locale = UtilMisc.parseLocale(localeString);
+ locale = UtilMisc.parseLocale(localeString)
}
}
- variantPriceList = [];
- numberFormat = NumberFormat.getCurrencyInstance(locale);
+ variantPriceList = []
+ numberFormat = NumberFormat.getCurrencyInstance(locale)
if(virtualVariants){
- amt = new StringBuffer();
+ amt = new StringBuffer()
// Create the javascript to return the price for each variant
- variantPriceJS = new StringBuffer();
- variantPriceJS.append("function getVariantPrice(sku) { ");
+ variantPriceJS = new StringBuffer()
+ variantPriceJS.append("function getVariantPrice(sku) { ")
virtualVariants.each { virtualAssoc ->
- virtual = virtualAssoc.getRelatedOne("MainProduct", false);
+ virtual = virtualAssoc.getRelatedOne("MainProduct", false)
// Get price from a virtual product
- priceContext.product = virtual;
+ priceContext.product = virtual
if (cart.isSalesOrder()) {
// sales order: run the "calculateProductPrice" service
- virtualPriceMap = runService('calculateProductPrice', priceContext);
- BigDecimal calculatedPrice = (BigDecimal)virtualPriceMap.get("price");
+ virtualPriceMap = runService('calculateProductPrice', priceContext)
+ BigDecimal calculatedPrice = (BigDecimal)virtualPriceMap.get("price")
// Get the minimum quantity for variants if MINIMUM_ORDER_PRICE is set for variants.
- variantPriceList.add(virtualPriceMap);
+ variantPriceList.add(virtualPriceMap)
} else {
- virtualPriceMap = runService('calculatePurchasePrice', priceContext);
+ virtualPriceMap = runService('calculatePurchasePrice', priceContext)
}
if (virtualPriceMap.basePrice) {
- basePrice = numberFormat.format(virtualPriceMap.basePrice);
+ basePrice = numberFormat.format(virtualPriceMap.basePrice)
} else {
basePrice = UtilProperties.getResourceBundleMap("CommonUiLabels", locale).get("CommonNA")
}
- variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + basePrice + "\"; ");
+ variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + basePrice + "\"; ")
}
- variantPriceJS.append(" } ");
+ variantPriceJS.append(" } ")
- context.variantPriceList = variantPriceList;
- jsBuf.append(amt.toString());
- jsBuf.append(variantPriceJS.toString());
- jsBuf.append("</script>");
- context.virtualJavaScript = jsBuf;
+ context.variantPriceList = variantPriceList
+ jsBuf.append(amt.toString())
+ jsBuf.append(variantPriceJS.toString())
+ jsBuf.append("</script>")
+ context.virtualJavaScript = jsBuf
}
}
- context.mainProducts = mainProducts;
+ context.mainProducts = mainProducts
}
// get the average rating
if (reviews) {
- totalProductRating = 0;
- numRatings = 0;
+ totalProductRating = 0
+ numRatings = 0
reviews.each { productReview ->
- productRating = productReview.productRating;
+ productRating = productReview.productRating
if (productRating) {
- totalProductRating += productRating;
- numRatings++;
+ totalProductRating += productRating
+ numRatings++
}
}
if (numRatings) {
- context.averageRating = totalProductRating/numRatings;
- context.numRatings = numRatings;
+ context.averageRating = totalProductRating/numRatings
+ context.numRatings = numRatings
}
}
// an example of getting features of a certain type to show
-sizeProductFeatureAndAppls = from("ProductFeatureAndAppl").where("productId", productId, "productFeatureTypeId", "SIZE").orderBy("sequenceNum", "defaultSequenceNum").cache(true).queryList();
+sizeProductFeatureAndAppls = from("ProductFeatureAndAppl").where("productId", productId, "productFeatureTypeId", "SIZE").orderBy("sequenceNum", "defaultSequenceNum").cache(true).queryList()
-context.product = product;
-context.categoryId = categoryId;
-context.productReviews = reviews;
-context.sizeProductFeatureAndAppls = sizeProductFeatureAndAppls;
+context.product = product
+context.categoryId = categoryId
+context.productReviews = reviews
+context.sizeProductFeatureAndAppls = sizeProductFeatureAndAppls
Modified: ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ProductUomDropDownOnly.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ProductUomDropDownOnly.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ProductUomDropDownOnly.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ProductUomDropDownOnly.groovy Wed Nov 2 19:09:13 2016
@@ -17,23 +17,23 @@
* under the License.
*/
-import org.apache.ofbiz.base.util.*;
+import org.apache.ofbiz.base.util.*
-product = from("Product").where("productId", parameters.productId).queryOne();
+product = from("Product").where("productId", parameters.productId).queryOne()
if (product) {
- productVirtualVariants = from("ProductAssoc").where("productIdTo", product.productId , "productAssocTypeId", "ALTERNATIVE_PACKAGE").cache(true).queryList();
+ productVirtualVariants = from("ProductAssoc").where("productIdTo", product.productId , "productAssocTypeId", "ALTERNATIVE_PACKAGE").cache(true).queryList()
if(productVirtualVariants){
- def mainProducts = [];
+ def mainProducts = []
productVirtualVariants.each { virtualVariantKey ->
- mainProductMap = [:];
- mainProduct = virtualVariantKey.getRelatedOne("MainProduct", true);
- quantityUom = mainProduct.getRelatedOne("QuantityUom", true);
- mainProductMap.productId = mainProduct.productId;
- mainProductMap.piecesIncluded = mainProduct.piecesIncluded;
- mainProductMap.uomDesc = quantityUom.description;
- mainProducts.add(mainProductMap);
+ mainProductMap = [:]
+ mainProduct = virtualVariantKey.getRelatedOne("MainProduct", true)
+ quantityUom = mainProduct.getRelatedOne("QuantityUom", true)
+ mainProductMap.productId = mainProduct.productId
+ mainProductMap.piecesIncluded = mainProduct.piecesIncluded
+ mainProductMap.uomDesc = quantityUom.description
+ mainProducts.add(mainProductMap)
}
- context.mainProducts = mainProducts;
+ context.mainProducts = mainProducts
}
- context.product = product;
+ context.product = product
}
Modified: ofbiz/trunk/applications/order/groovyScripts/entry/catalog/QuickAdd.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/entry/catalog/QuickAdd.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/entry/catalog/QuickAdd.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/entry/catalog/QuickAdd.groovy Wed Nov 2 19:09:13 2016
@@ -22,29 +22,29 @@
* should not contain order component's specific code.
*/
-import java.lang.*;
-import java.util.*;
-import org.apache.ofbiz.base.util.*;
-import org.apache.ofbiz.entity.*;
-import org.apache.ofbiz.service.*;
-import org.apache.ofbiz.product.catalog.*;
+import java.lang.*
+import java.util.*
+import org.apache.ofbiz.base.util.*
+import org.apache.ofbiz.entity.*
+import org.apache.ofbiz.service.*
+import org.apache.ofbiz.product.catalog.*
-currentCatalogId = CatalogWorker.getCurrentCatalogId(request);
-categoryId = parameters.category_id ?: CatalogWorker.getCatalogQuickaddCategoryPrimary(request);
+currentCatalogId = CatalogWorker.getCurrentCatalogId(request)
+categoryId = parameters.category_id ?: CatalogWorker.getCatalogQuickaddCategoryPrimary(request)
-quickAddCategories = CatalogWorker.getCatalogQuickaddCategories(request);
-context.quickAddCats = quickAddCategories;
-context.categoryId = categoryId;
+quickAddCategories = CatalogWorker.getCatalogQuickaddCategories(request)
+context.quickAddCats = quickAddCategories
+context.categoryId = categoryId
if (categoryId) {
fields = [productCategoryId : categoryId, defaultViewSize : 10,
- limitView : false, prodCatalogId : currentCatalogId, checkViewAllow : true];
- result = runService('getProductCategoryAndLimitedMembers', fields);
+ limitView : false, prodCatalogId : currentCatalogId, checkViewAllow : true]
+ result = runService('getProductCategoryAndLimitedMembers', fields)
if (result) {
result.each { key, value ->
- context[key] = value;
+ context[key] = value
}
}
- productCategory = from("ProductCategory").where("productCategoryId", categoryId).queryOne();
- context.productCategory = productCategory;
+ productCategory = from("ProductCategory").where("productCategoryId", categoryId).queryOne()
+ context.productCategory = productCategory
}
Modified: ofbiz/trunk/applications/order/groovyScripts/entry/catalog/SideDeepCategory.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/entry/catalog/SideDeepCategory.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/entry/catalog/SideDeepCategory.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/entry/catalog/SideDeepCategory.groovy Wed Nov 2 19:09:13 2016
@@ -22,18 +22,18 @@
* should not contain order component's specific code.
*/
-import org.apache.ofbiz.base.util.*;
-import org.apache.ofbiz.product.catalog.*;
-import org.apache.ofbiz.product.category.*;
+import org.apache.ofbiz.base.util.*
+import org.apache.ofbiz.product.catalog.*
+import org.apache.ofbiz.product.category.*
-CategoryWorker.getRelatedCategories(request, "topLevelList", CatalogWorker.getCatalogTopCategoryId(request, CatalogWorker.getCurrentCatalogId(request)), true);
-curCategoryId = parameters.category_id ?: parameters.CATEGORY_ID ?: "";
-request.setAttribute("curCategoryId", curCategoryId);
-CategoryWorker.setTrail(request, curCategoryId);
+CategoryWorker.getRelatedCategories(request, "topLevelList", CatalogWorker.getCatalogTopCategoryId(request, CatalogWorker.getCurrentCatalogId(request)), true)
+curCategoryId = parameters.category_id ?: parameters.CATEGORY_ID ?: ""
+request.setAttribute("curCategoryId", curCategoryId)
+CategoryWorker.setTrail(request, curCategoryId)
-categoryList = request.getAttribute("topLevelList");
+categoryList = request.getAttribute("topLevelList")
if (categoryList) {
- catContentWrappers = [:];
- CategoryWorker.getCategoryContentWrappers(catContentWrappers, categoryList, request);
- context.catContentWrappers = catContentWrappers;
+ catContentWrappers = [:]
+ CategoryWorker.getCategoryContentWrappers(catContentWrappers, categoryList, request)
+ context.catContentWrappers = catContentWrappers
}
Modified: ofbiz/trunk/applications/order/groovyScripts/lookup/LookupAssociatedProducts.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/lookup/LookupAssociatedProducts.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/lookup/LookupAssociatedProducts.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/lookup/LookupAssociatedProducts.groovy Wed Nov 2 19:09:13 2016
@@ -17,28 +17,28 @@
* under the License.
*/
-import org.apache.ofbiz.base.util.UtilValidate;
-import org.apache.ofbiz.entity.condition.EntityCondition;
-import org.apache.ofbiz.entity.condition.EntityOperator;
-import org.apache.ofbiz.entity.util.EntityUtil;
+import org.apache.ofbiz.base.util.UtilValidate
+import org.apache.ofbiz.entity.condition.EntityCondition
+import org.apache.ofbiz.entity.condition.EntityOperator
+import org.apache.ofbiz.entity.util.EntityUtil
-productId = request.getParameter("productId");
+productId = request.getParameter("productId")
if (productId != null) {
- product = from("Product").where("productId", productId).queryOne();
- prodAssocs = product.getRelated("MainProductAssoc", null, null, false);
+ product = from("Product").where("productId", productId).queryOne()
+ prodAssocs = product.getRelated("MainProductAssoc", null, null, false)
if (UtilValidate.isNotEmpty(prodAssocs)) {
- products = EntityUtil.filterByAnd(prodAssocs, [EntityCondition.makeCondition("productAssocTypeId", EntityOperator.NOT_EQUAL, "PRODUCT_VARIANT")]);
+ products = EntityUtil.filterByAnd(prodAssocs, [EntityCondition.makeCondition("productAssocTypeId", EntityOperator.NOT_EQUAL, "PRODUCT_VARIANT")])
if (UtilValidate.isNotEmpty(products)) {
- productList = [];
+ productList = []
products.each { product ->
if (product != null) {
- String productIdTo = product.getString("productIdTo");
- productList.add(from("Product").where("productId", productIdTo).queryFirst());
+ String productIdTo = product.getString("productIdTo")
+ productList.add(from("Product").where("productId", productIdTo).queryFirst())
}
}
- context.put("productList",productList);
+ context.put("productList",productList)
}
}
}