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 [10/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/CategoryDetail.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/entry/catalog/CategoryDetail.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/entry/catalog/CategoryDetail.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/entry/catalog/CategoryDetail.groovy Wed Nov 2 19:09:13 2016
@@ -22,88 +22,88 @@
* should not contain order component's specific code.
*/
-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.product.catalog.*;
-import org.apache.ofbiz.product.category.CategoryContentWrapper;
-import org.apache.ofbiz.product.store.ProductStoreWorker;
-
-productCategoryId = request.getAttribute("productCategoryId");
-context.productCategoryId = productCategoryId;
-
-viewSize = parameters.VIEW_SIZE;
-viewIndex = parameters.VIEW_INDEX;
-currentCatalogId = CatalogWorker.getCurrentCatalogId(request);
+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.product.catalog.*
+import org.apache.ofbiz.product.category.CategoryContentWrapper
+import org.apache.ofbiz.product.store.ProductStoreWorker
+
+productCategoryId = request.getAttribute("productCategoryId")
+context.productCategoryId = productCategoryId
+
+viewSize = parameters.VIEW_SIZE
+viewIndex = parameters.VIEW_INDEX
+currentCatalogId = CatalogWorker.getCurrentCatalogId(request)
// set the default view size
-defaultViewSize = request.getAttribute("defaultViewSize") ?: EntityUtilProperties.getPropertyValue("widget", "widget.form.defaultViewSize", "20", delegator);
-context.defaultViewSize = defaultViewSize;
+defaultViewSize = request.getAttribute("defaultViewSize") ?: EntityUtilProperties.getPropertyValue("widget", "widget.form.defaultViewSize", "20", delegator)
+context.defaultViewSize = defaultViewSize
// set the limit view
-limitView = request.getAttribute("limitView") ?: true;
-context.limitView = limitView;
+limitView = request.getAttribute("limitView") ?: true
+context.limitView = limitView
// get the product category & members
andMap = [productCategoryId : productCategoryId,
viewIndexString : viewIndex,
viewSizeString : viewSize,
defaultViewSize : defaultViewSize,
- limitView : limitView];
-andMap.put("prodCatalogId", currentCatalogId);
-andMap.put("checkViewAllow", true);
+ limitView : limitView]
+andMap.put("prodCatalogId", currentCatalogId)
+andMap.put("checkViewAllow", true)
// Prevents out of stock product to be displayed on site
-productStore = ProductStoreWorker.getProductStore(request);
+productStore = ProductStoreWorker.getProductStore(request)
if (productStore) {
- andMap.put("productStoreId", productStore.productStoreId);
+ andMap.put("productStoreId", productStore.productStoreId)
}
if (context.orderByFields) {
- andMap.put("orderByFields", context.orderByFields);
+ andMap.put("orderByFields", context.orderByFields)
} else {
- andMap.put("orderByFields", ["sequenceNum", "productId"]);
+ andMap.put("orderByFields", ["sequenceNum", "productId"])
}
-catResult = runService('getProductCategoryAndLimitedMembers', andMap);
-productCategory = catResult.productCategory;
-productCategoryMembers = catResult.productCategoryMembers;
-context.productCategoryMembers = productCategoryMembers;
-context.productCategory = productCategory;
-context.viewIndex = catResult.viewIndex;
-context.viewSize = catResult.viewSize;
-context.lowIndex = catResult.lowIndex;
-context.highIndex = catResult.highIndex;
-context.listSize = catResult.listSize;
+catResult = runService('getProductCategoryAndLimitedMembers', andMap)
+productCategory = catResult.productCategory
+productCategoryMembers = catResult.productCategoryMembers
+context.productCategoryMembers = productCategoryMembers
+context.productCategory = productCategory
+context.viewIndex = catResult.viewIndex
+context.viewSize = catResult.viewSize
+context.lowIndex = catResult.lowIndex
+context.highIndex = catResult.highIndex
+context.listSize = catResult.listSize
// set this as a last viewed
// DEJ20070220: WHY is this done this way? why not use the existing CategoryWorker stuff?
-LAST_VIEWED_TO_KEEP = 10; // modify this to change the number of last viewed to keep
-lastViewedCategories = session.getAttribute("lastViewedCategories");
+LAST_VIEWED_TO_KEEP = 10 // modify this to change the number of last viewed to keep
+lastViewedCategories = session.getAttribute("lastViewedCategories")
if (!lastViewedCategories) {
- lastViewedCategories = [];
- session.setAttribute("lastViewedCategories", lastViewedCategories);
+ lastViewedCategories = []
+ session.setAttribute("lastViewedCategories", lastViewedCategories)
}
-lastViewedCategories.remove(productCategoryId);
-lastViewedCategories.add(0, productCategoryId);
+lastViewedCategories.remove(productCategoryId)
+lastViewedCategories.add(0, productCategoryId)
while (lastViewedCategories.size() > LAST_VIEWED_TO_KEEP) {
- lastViewedCategories.remove(lastViewedCategories.size() - 1);
+ lastViewedCategories.remove(lastViewedCategories.size() - 1)
}
// set the content path prefix
-contentPathPrefix = CatalogWorker.getContentPathPrefix(request);
-context.put("contentPathPrefix", contentPathPrefix);
+contentPathPrefix = CatalogWorker.getContentPathPrefix(request)
+context.put("contentPathPrefix", contentPathPrefix)
// little routine to see if any members have a quantity > 0 assigned
-members = context.get("productCategoryMembers");
+members = context.get("productCategoryMembers")
if (UtilValidate.isNotEmpty(members)) {
for (i = 0; i < members.size(); i++) {
- productCategoryMember = (GenericValue) members.get(i);
+ productCategoryMember = (GenericValue) members.get(i)
if (productCategoryMember.get("quantity") != null && productCategoryMember.getDouble("quantity").doubleValue() > 0.0) {
- context.put("hasQuantities", new Boolean(true));
- break;
+ context.put("hasQuantities", new Boolean(true))
+ break
}
}
}
-CategoryContentWrapper categoryContentWrapper = new CategoryContentWrapper(productCategory, request);
-context.put("categoryContentWrapper", categoryContentWrapper);
+CategoryContentWrapper categoryContentWrapper = new CategoryContentWrapper(productCategory, request)
+context.put("categoryContentWrapper", categoryContentWrapper)
Modified: ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ChooseCatalog.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ChooseCatalog.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ChooseCatalog.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/entry/catalog/ChooseCatalog.groovy Wed Nov 2 19:09:13 2016
@@ -17,33 +17,33 @@
* under the License.
*/
-import org.apache.ofbiz.base.util.*;
-import org.apache.ofbiz.entity.util.*;
-import org.apache.ofbiz.product.catalog.*;
-import org.apache.ofbiz.order.shoppingcart.*;
-import org.apache.ofbiz.product.store.ProductStoreWorker;
-
-catalogCol = null;
-currentCatalogId = null;
-currentCatalogName = null;
-
-cart = ShoppingCartEvents.getCartObject(request);
-productStoreId = cart.getProductStoreId();
-partyId = cart.getOrderPartyId();
+import org.apache.ofbiz.base.util.*
+import org.apache.ofbiz.entity.util.*
+import org.apache.ofbiz.product.catalog.*
+import org.apache.ofbiz.order.shoppingcart.*
+import org.apache.ofbiz.product.store.ProductStoreWorker
+
+catalogCol = null
+currentCatalogId = null
+currentCatalogName = null
+
+cart = ShoppingCartEvents.getCartObject(request)
+productStoreId = cart.getProductStoreId()
+partyId = cart.getOrderPartyId()
-currentCatalogId = CatalogWorker.getCurrentCatalogId(request);
+currentCatalogId = CatalogWorker.getCurrentCatalogId(request)
if ("SALES_ORDER".equals(cart.getOrderType())) {
- catalogCol = CatalogWorker.getCatalogIdsAvailable(delegator, productStoreId, partyId);
+ catalogCol = CatalogWorker.getCatalogIdsAvailable(delegator, productStoreId, partyId)
} else {
- catalogCol = CatalogWorker.getAllCatalogIds(request);
+ catalogCol = CatalogWorker.getAllCatalogIds(request)
if (!currentCatalogId && catalogCol) {
- currentCatalogId = catalogCol.get(0);
+ currentCatalogId = catalogCol.get(0)
}
- session.setAttribute("CURRENT_CATALOG_ID", currentCatalogId);
+ session.setAttribute("CURRENT_CATALOG_ID", currentCatalogId)
}
-currentCatalogName = CatalogWorker.getCatalogName(request, currentCatalogId);
+currentCatalogName = CatalogWorker.getCatalogName(request, currentCatalogId)
-context.catalogCol = catalogCol;
-context.currentCatalogId = currentCatalogId;
-context.currentCatalogName = currentCatalogName;
+context.catalogCol = catalogCol
+context.currentCatalogId = currentCatalogId
+context.currentCatalogName = currentCatalogName
Modified: ofbiz/trunk/applications/order/groovyScripts/entry/catalog/CompareProducts.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/entry/catalog/CompareProducts.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/entry/catalog/CompareProducts.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/entry/catalog/CompareProducts.groovy Wed Nov 2 19:09:13 2016
@@ -17,63 +17,63 @@
* under the License.
*/
-import org.apache.ofbiz.product.product.*;
-import org.apache.ofbiz.order.shoppingcart.*;
-import org.apache.ofbiz.product.catalog.*;
-import org.apache.ofbiz.product.store.*;
-import org.apache.ofbiz.entity.condition.*;
-import org.apache.ofbiz.entity.util.*;
-import org.apache.ofbiz.base.util.*;
-
-compareList = ProductEvents.getProductCompareList(request);
-context.compareList = compareList;
-cart = ShoppingCartEvents.getCartObject(request);
-catalogId = CatalogWorker.getCurrentCatalogId(request);
-productStore = ProductStoreWorker.getProductStore(request);
-productStoreId = productStore.productStoreId;
-
-productDataMap = [:];
-context.productDataMap = productDataMap;
-productFeatureTypeIds = [] as LinkedHashSet;
-context.productFeatureTypeIds = productFeatureTypeIds;
-productFeatureTypeMap = [:];
-context.productFeatureTypeMap = productFeatureTypeMap;
+import org.apache.ofbiz.product.product.*
+import org.apache.ofbiz.order.shoppingcart.*
+import org.apache.ofbiz.product.catalog.*
+import org.apache.ofbiz.product.store.*
+import org.apache.ofbiz.entity.condition.*
+import org.apache.ofbiz.entity.util.*
+import org.apache.ofbiz.base.util.*
+
+compareList = ProductEvents.getProductCompareList(request)
+context.compareList = compareList
+cart = ShoppingCartEvents.getCartObject(request)
+catalogId = CatalogWorker.getCurrentCatalogId(request)
+productStore = ProductStoreWorker.getProductStore(request)
+productStoreId = productStore.productStoreId
+
+productDataMap = [:]
+context.productDataMap = productDataMap
+productFeatureTypeIds = [] as LinkedHashSet
+context.productFeatureTypeIds = productFeatureTypeIds
+productFeatureTypeMap = [:]
+context.productFeatureTypeMap = productFeatureTypeMap
compareList.each { product ->
- productData = [:];
- productDataMap[product.productId] = productData;
+ productData = [:]
+ productDataMap[product.productId] = productData
- productData.productContentWrapper = ProductContentWrapper.makeProductContentWrapper(product, request);
+ productData.productContentWrapper = ProductContentWrapper.makeProductContentWrapper(product, request)
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";
- productData.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"
+ productData.priceMap = runService('calculateProductPrice', priceContext)
condList = [
EntityCondition.makeCondition("productId", product.productId),
EntityUtil.getFilterByDateExpr(),
EntityCondition.makeCondition("productFeatureApplTypeId", EntityOperator.IN, ["STANDARD_FEATURE", "DISTINGUISHING_FEAT", "SELECTABLE_FEATURE"])
- ];
- productFeatureAppls = from("ProductFeatureAppl").where(condList).orderBy("sequenceNum").cache(true).queryList();
+ ]
+ productFeatureAppls = from("ProductFeatureAppl").where(condList).orderBy("sequenceNum").cache(true).queryList()
productFeatureAppls.each { productFeatureAppl ->
- productFeature = productFeatureAppl.getRelatedOne("ProductFeature", true);
+ productFeature = productFeatureAppl.getRelatedOne("ProductFeature", true)
if (!productData[productFeature.productFeatureTypeId]) {
- productData[productFeature.productFeatureTypeId] = [:];
+ productData[productFeature.productFeatureTypeId] = [:]
}
if (!productData[productFeature.productFeatureTypeId][productFeatureAppl.productFeatureApplTypeId]) {
- productData[productFeature.productFeatureTypeId][productFeatureAppl.productFeatureApplTypeId] = [];
+ productData[productFeature.productFeatureTypeId][productFeatureAppl.productFeatureApplTypeId] = []
}
- productData[productFeature.productFeatureTypeId][productFeatureAppl.productFeatureApplTypeId] << productFeature;
- productFeatureTypeIds << productFeature.productFeatureTypeId;
+ productData[productFeature.productFeatureTypeId][productFeatureAppl.productFeatureApplTypeId] << productFeature
+ productFeatureTypeIds << productFeature.productFeatureTypeId
}
}
productFeatureTypeIds.each { productFeatureTypeId ->
- productFeatureTypeMap[productFeatureTypeId] = from("ProductFeatureType").where("productFeatureTypeId", productFeatureTypeId).cache(true).queryOne();
+ productFeatureTypeMap[productFeatureTypeId] = from("ProductFeatureType").where("productFeatureTypeId", productFeatureTypeId).cache(true).queryOne()
}
Modified: ofbiz/trunk/applications/order/groovyScripts/entry/catalog/InlineProductDetail.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/entry/catalog/InlineProductDetail.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/entry/catalog/InlineProductDetail.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/entry/catalog/InlineProductDetail.groovy Wed Nov 2 19:09:13 2016
@@ -17,291 +17,291 @@
* under the License.
*/
-import java.lang.*;
-import java.util.*;
-import java.text.NumberFormat;
-import org.apache.ofbiz.base.util.*;
-import org.apache.ofbiz.service.*;
-import org.apache.ofbiz.entity.*;
-import org.apache.ofbiz.entity.condition.*;
-import org.apache.ofbiz.entity.util.*;
-import org.apache.ofbiz.webapp.taglib.ContentUrlTag;
-import org.apache.ofbiz.webapp.stats.VisitHandler;
+import java.lang.*
+import java.util.*
+import java.text.NumberFormat
+import org.apache.ofbiz.base.util.*
+import org.apache.ofbiz.service.*
+import org.apache.ofbiz.entity.*
+import org.apache.ofbiz.entity.condition.*
+import org.apache.ofbiz.entity.util.*
+import org.apache.ofbiz.webapp.taglib.ContentUrlTag
+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.product.catalog.*;
-import org.apache.ofbiz.product.category.*;
-import org.apache.ofbiz.product.product.ProductWorker;
-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.store.*;
-
-inlineProductId = request.getAttribute("inlineProductId");
-inlineCounter = request.getAttribute("inlineCounter");
-context.inlineCounter = inlineCounter;
-context.inlineProductId = inlineProductId;
-
-contentPathPrefix = CatalogWorker.getContentPathPrefix(request);
-catalogName = CatalogWorker.getCatalogName(request);
-currentCatalogId = CatalogWorker.getCurrentCatalogId(request);
+import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents
+import org.apache.ofbiz.product.catalog.*
+import org.apache.ofbiz.product.category.*
+import org.apache.ofbiz.product.product.ProductWorker
+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.store.*
+
+inlineProductId = request.getAttribute("inlineProductId")
+inlineCounter = request.getAttribute("inlineCounter")
+context.inlineCounter = inlineCounter
+context.inlineProductId = inlineProductId
+
+contentPathPrefix = CatalogWorker.getContentPathPrefix(request)
+catalogName = CatalogWorker.getCatalogName(request)
+currentCatalogId = CatalogWorker.getCurrentCatalogId(request)
if (inlineProductId) {
- inlineProduct = from("Product").where("productId", inlineProductId).cache(true).queryOne();
+ inlineProduct = from("Product").where("productId", inlineProductId).cache(true).queryOne()
if (inlineProduct) {
- context.product = inlineProduct;
- contentWrapper = new ProductContentWrapper(inlineProduct, request);
- context.put("title", contentWrapper.get("PRODUCT_NAME", "html"));
- context.put("metaDescription", contentWrapper.get("DESCRIPTION", "html"));
- productTemplate = product.detailScreen;
+ context.product = inlineProduct
+ contentWrapper = new ProductContentWrapper(inlineProduct, request)
+ context.put("title", contentWrapper.get("PRODUCT_NAME", "html"))
+ context.put("metaDescription", contentWrapper.get("DESCRIPTION", "html"))
+ productTemplate = product.detailScreen
if (productTemplate) {
- detailScreen = productTemplate;
+ detailScreen = productTemplate
}
}
}
-templatePathPrefix = CatalogWorker.getTemplatePathPrefix(request);
+templatePathPrefix = CatalogWorker.getTemplatePathPrefix(request)
if (templatePathPrefix) {
- detailScreen = templatePathPrefix + detailScreen;
+ detailScreen = templatePathPrefix + detailScreen
}
-context.detailScreen = detailScreen;
+context.detailScreen = detailScreen
String buildNext(Map map, List order, String current, String prefix, Map featureTypes) {
- def ct = 0;
- def buf = new StringBuffer();
- buf.append("function listFT" + inlineCounter + current + prefix + "() { ");
- buf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter + current + "\"].options.length = 1;");
- buf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter + current + "\"].options[0] = new Option(\"" + featureTypes[current] + "\",\"\",true,true);");
+ def ct = 0
+ def buf = new StringBuffer()
+ buf.append("function listFT" + inlineCounter + current + prefix + "() { ")
+ buf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter + current + "\"].options.length = 1;")
+ buf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter + 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[\"configform\"].elements[\"FT" + inlineCounter + current + "\"].options[" + (ct + 1) + "] = new Option(\"" + key + "\",\"" + optValue + "\");");
- ct++;
+ buf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter + 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 the content path prefix
-contentPathPrefix = CatalogWorker.getContentPathPrefix(request);
-context.contentPathPrefix = contentPathPrefix;
+contentPathPrefix = CatalogWorker.getContentPathPrefix(request)
+context.contentPathPrefix = contentPathPrefix
// get the product detail information
if (inlineProduct) {
- inlineProductId = inlineProduct.productId;
- productTypeId = inlineProduct.productTypeId;
- featureTypes = [:];
- featureOrder = [];
+ inlineProductId = inlineProduct.productId
+ productTypeId = inlineProduct.productTypeId
+ featureTypes = [:]
+ featureOrder = []
// make the productContentWrapper
- productContentWrapper = new ProductContentWrapper(inlineProduct, request);
- context.productContentWrapper = productContentWrapper;
+ productContentWrapper = new ProductContentWrapper(inlineProduct, 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 the product price
- webSiteId = WebSiteWorker.getWebSiteId(request);
- autoUserLogin = request.getSession().getAttribute("autoUserLogin");
+ webSiteId = WebSiteWorker.getWebSiteId(request)
+ autoUserLogin = request.getSession().getAttribute("autoUserLogin")
if (cart.isSalesOrder()) {
// sales order: run the "calculateProductPrice" service
priceContext = [product : inlineProduct, prodCatalogId : currentCatalogId,
- 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 : inlineProduct, 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
}
- context.variantTree = null;
- context.variantTreeSize = null;
- context.variantSample = null;
- context.variantSampleKeys = null;
- context.variantSampleSize = null;
+ context.variantTree = null
+ context.variantTreeSize = null
+ context.variantSample = null
+ context.variantSampleKeys = null
+ context.variantSampleSize = null
if ("Y".equals(inlineProduct.isVirtual)) {
if ("VV_FEATURETREE".equals(ProductWorker.getProductVirtualVariantMethod(delegator, inlineProductId))) {
- context.featureLists = ProductWorker.getSelectableProductFeaturesByTypesAndSeq(inlineProduct);
+ context.featureLists = ProductWorker.getSelectableProductFeaturesByTypesAndSeq(inlineProduct)
} else {
- featureMap = runService("getProductFeatureSet", [productId : inlineProductId]);
- featureSet = featureMap.featureSet;
+ featureMap = runService("getProductFeatureSet", [productId : inlineProductId])
+ featureSet = featureMap.featureSet
if (featureSet) {
- variantTreeMap = runService('getProductVariantTree', [productId : inlineProductId, featureOrder : featureSet, productStoreId : productStoreId]);
- variantTree = variantTreeMap.variantTree;
- imageMap = variantTreeMap.variantSample;
- virtualVariant = variantTreeMap.virtualVariant;
- context.virtualVariant = virtualVariant;
+ variantTreeMap = runService('getProductVariantTree', [productId : inlineProductId, featureOrder : featureSet, productStoreId : productStoreId])
+ 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()
}
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" + inlineCounter + "= new Array(" + variantTree.size() + ");");
- jsBuf.append("var IMG" + inlineCounter + " = new Array(" + variantTree.size() + ");");
- jsBuf.append("var OPT" + inlineCounter + " = new Array(" + featureOrder.size() + ");");
- jsBuf.append("var VIR" + inlineCounter + " = new Array(" + virtualVariant.size() + ");");
- jsBuf.append("var detailImageUrl" + inlineCounter + " = null;");
+ jsBuf = new StringBuffer()
+ jsBuf.append("<script language=\"JavaScript\" type=\"text/javascript\">")
+ jsBuf.append("var DET" + inlineCounter + "= new Array(" + variantTree.size() + ");")
+ jsBuf.append("var IMG" + inlineCounter + " = new Array(" + variantTree.size() + ");")
+ jsBuf.append("var OPT" + inlineCounter + " = new Array(" + featureOrder.size() + ");")
+ jsBuf.append("var VIR" + inlineCounter + " = new Array(" + virtualVariant.size() + ");")
+ jsBuf.append("var detailImageUrl" + inlineCounter + " = null;")
featureOrder.eachWithIndex { feature, i ->
- jsBuf.append("OPT" + inlineCounter + "[" + i + "] = \"FT" + inlineCounter + feature + "\";");
+ jsBuf.append("OPT" + inlineCounter + "[" + i + "] = \"FT" + inlineCounter + feature + "\";")
}
virtualVariant.eachWithIndex { variant, i ->
- jsBuf.append("VIR" + inlineCounter + "[" + i + "] = \"" + variant + "\";");
+ jsBuf.append("VIR" + inlineCounter + "[" + i + "] = \"" + variant + "\";")
}
// build the top level
- topLevelName = featureOrder[0];
- jsBuf.append("function list" + inlineCounter + topLevelName + "() {");
- jsBuf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter + topLevelName + "\"].options.length = 1;");
- jsBuf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter + topLevelName + "\"].options[0] = new Option(\"" + featureTypes[topLevelName] + "\",\"\",true,true);");
+ topLevelName = featureOrder[0]
+ jsBuf.append("function list" + inlineCounter + topLevelName + "() {")
+ jsBuf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter + topLevelName + "\"].options.length = 1;")
+ jsBuf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter + topLevelName + "\"].options[0] = new Option(\"" + featureTypes[topLevelName] + "\",\"\",true,true);")
if (variantTree) {
featureOrder.each { featureKey ->
- jsBuf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter + featureKey + "\"].options.length = 1;");
+ jsBuf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter + 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;
+ detailImageUrl = ContentUrlTag.getContentPrefix(request) + detailImage
}
if (largeImage) {
- largeImageUrl = ContentUrlTag.getContentPrefix(request) + largeImage;
+ largeImageUrl = ContentUrlTag.getContentPrefix(request) + largeImage
}
- jsBuf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter + topLevelName + "\"].options[" + (counter+1) + "] = new Option(\"" + key + "\",\"" + opt + "\");");
- jsBuf.append("DET" + inlineCounter + "[" + counter + "] = \"" + detailImageUrl +"\";");
- jsBuf.append("IMG" + inlineCounter + "[" + counter + "] = \"" + largeImageUrl +"\";");
+ jsBuf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter + topLevelName + "\"].options[" + (counter+1) + "] = new Option(\"" + key + "\",\"" + opt + "\");")
+ jsBuf.append("DET" + inlineCounter + "[" + counter + "] = \"" + detailImageUrl +"\";")
+ jsBuf.append("IMG" + inlineCounter + "[" + 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 : inlineProductId, type : "PRODUCT_VARIANT", checkViewAllow : true, prodCatalogId : currentCatalogId]);
- variants = variantsRes.assocProducts;
+ variantsRes = runService('getAssociatedProducts', [productId : inlineProductId, type : "PRODUCT_VARIANT", checkViewAllow : true, prodCatalogId : currentCatalogId])
+ variants = variantsRes.assocProducts
if (variants) {
- amt = new StringBuffer();
- amt.append("function checkAmtReq" + inlineCounter + "(sku) { ");
+ amt = new StringBuffer()
+ amt.append("function checkAmtReq" + inlineCounter + "(sku) { ")
// Create the javascript to return the price for each variant
- variantPriceJS = new StringBuffer();
- variantPriceJS.append("function getVariantPrice" + inlineCounter + "(sku) { ");
+ variantPriceJS = new StringBuffer()
+ variantPriceJS.append("function getVariantPrice" + inlineCounter + "(sku) { ")
// Format to apply the currency code to the variant price in the javascript
- productStore = ProductStoreWorker.getProductStore(request);
- localeString = productStore.defaultLocaleString;
+ productStore = ProductStoreWorker.getProductStore(request)
+ localeString = productStore.defaultLocaleString
if (localeString) {
- locale = UtilMisc.parseLocale(localeString);
+ locale = UtilMisc.parseLocale(localeString)
}
- numberFormat = NumberFormat.getCurrencyInstance(locale);
+ numberFormat = NumberFormat.getCurrencyInstance(locale)
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
if (cart.isSalesOrder()) {
// sales order: run the "calculateProductPrice" service
- priceContext.product = variant;
- variantPriceMap = runService('calculateProductPrice', priceContext);
+ priceContext.product = variant
+ variantPriceMap = runService('calculateProductPrice', priceContext)
}
- amt.append(" if (sku == \"" + variant.productId + "\") return \"" + (variant.requireAmount ?: "N") + "\"; ");
- variantPriceJS.append(" if (sku == \"" + variant.productId + "\") return \"" + numberFormat.format(variantPriceMap.basePrice) + "\"; ");
+ amt.append(" if (sku == \"" + variant.productId + "\") return \"" + (variant.requireAmount ?: "N") + "\"; ")
+ variantPriceJS.append(" if (sku == \"" + variant.productId + "\") return \"" + numberFormat.format(variantPriceMap.basePrice) + "\"; ")
}
- amt.append(" } ");
- variantPriceJS.append(" } ");
+ amt.append(" } ")
+ variantPriceJS.append(" } ")
}
- jsBuf.append(amt.toString());
- jsBuf.append(variantPriceJS.toString());
- jsBuf.append("</script>");
+ jsBuf.append(amt.toString())
+ jsBuf.append(variantPriceJS.toString())
+ jsBuf.append("</script>")
- context.virtualJavaScript = jsBuf;
+ context.virtualJavaScript = jsBuf
}
}
}
Modified: ofbiz/trunk/applications/order/groovyScripts/entry/catalog/KeywordSearch.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/entry/catalog/KeywordSearch.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/entry/catalog/KeywordSearch.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/entry/catalog/KeywordSearch.groovy Wed Nov 2 19:09:13 2016
@@ -22,25 +22,25 @@
* 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.feature.*;
-import org.apache.ofbiz.product.product.*;
+import org.apache.ofbiz.base.util.*
+import org.apache.ofbiz.product.catalog.*
+import org.apache.ofbiz.product.feature.*
+import org.apache.ofbiz.product.product.*
-module = "KeywordSearch.groovy";
+module = "KeywordSearch.groovy"
// note: this can be run multiple times in the same request without causing problems, will check to see on its own if it has run again
-ProductSearchSession.processSearchParameters(parameters, request);
-prodCatalogId = CatalogWorker.getCurrentCatalogId(request);
-result = ProductSearchSession.getProductSearchResult(request, delegator, prodCatalogId);
+ProductSearchSession.processSearchParameters(parameters, request)
+prodCatalogId = CatalogWorker.getCurrentCatalogId(request)
+result = ProductSearchSession.getProductSearchResult(request, delegator, prodCatalogId)
-context.productIds = result.productIds;
-context.viewIndex = result.viewIndex;
-context.viewSize = result.viewSize;
-context.listSize = result.listSize;
-context.lowIndex = result.lowIndex;
-context.highIndex = result.highIndex;
-context.paging = result.paging;
-context.previousViewSize = result.previousViewSize;
-context.searchConstraintStrings = result.searchConstraintStrings;
-context.searchSortOrderString = result.searchSortOrderString;
+context.productIds = result.productIds
+context.viewIndex = result.viewIndex
+context.viewSize = result.viewSize
+context.listSize = result.listSize
+context.lowIndex = result.lowIndex
+context.highIndex = result.highIndex
+context.paging = result.paging
+context.previousViewSize = result.previousViewSize
+context.searchConstraintStrings = result.searchConstraintStrings
+context.searchSortOrderString = result.searchSortOrderString
Modified: ofbiz/trunk/applications/order/groovyScripts/entry/catalog/KeywordSearchOptions.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/entry/catalog/KeywordSearchOptions.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/entry/catalog/KeywordSearchOptions.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/entry/catalog/KeywordSearchOptions.groovy Wed Nov 2 19:09:13 2016
@@ -22,18 +22,18 @@
* should not contain order component's specific code.
*/
-import org.apache.ofbiz.product.catalog.*;
+import org.apache.ofbiz.product.catalog.*
-currentCatalogId = CatalogWorker.getCurrentCatalogId(request);
-searchCategoryId = CatalogWorker.getCatalogSearchCategoryId(request, currentCatalogId);
-otherSearchProdCatalogCategories = CatalogWorker.getProdCatalogCategories(request, currentCatalogId, "PCCT_OTHER_SEARCH");
+currentCatalogId = CatalogWorker.getCurrentCatalogId(request)
+searchCategoryId = CatalogWorker.getCatalogSearchCategoryId(request, currentCatalogId)
+otherSearchProdCatalogCategories = CatalogWorker.getProdCatalogCategories(request, currentCatalogId, "PCCT_OTHER_SEARCH")
-searchOperator = request.getParameter("SEARCH_OPERATOR");
+searchOperator = request.getParameter("SEARCH_OPERATOR")
if (!"AND".equals(searchOperator) && !"OR".equals(searchOperator)) {
- searchOperator = "OR";
+ searchOperator = "OR"
}
-context.currentCatalogId = currentCatalogId;
-context.searchCategoryId = searchCategoryId;
-context.otherSearchProdCatalogCategories = otherSearchProdCatalogCategories;
-context.searchOperator = searchOperator;
+context.currentCatalogId = currentCatalogId
+context.searchCategoryId = searchCategoryId
+context.otherSearchProdCatalogCategories = otherSearchProdCatalogCategories
+context.searchOperator = searchOperator
Modified: ofbiz/trunk/applications/order/groovyScripts/entry/catalog/PrepareConfigForm.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/entry/catalog/PrepareConfigForm.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/entry/catalog/PrepareConfigForm.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/entry/catalog/PrepareConfigForm.groovy Wed Nov 2 19:09:13 2016
@@ -22,33 +22,33 @@
* should not contain order component's specific code.
*/
-import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents;
-import org.apache.ofbiz.product.config.ProductConfigWorker;
-import org.apache.ofbiz.product.store.ProductStoreWorker;
-import org.apache.ofbiz.base.util.*;
+import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents
+import org.apache.ofbiz.product.config.ProductConfigWorker
+import org.apache.ofbiz.product.store.ProductStoreWorker
+import org.apache.ofbiz.base.util.*
-currencyUomId = ShoppingCartEvents.getCartObject(request).getCurrency();
-product = context.product;
+currencyUomId = ShoppingCartEvents.getCartObject(request).getCurrency()
+product = context.product
if (product) {
- configWrapper = ProductConfigWorker.getProductConfigWrapper(product.productId, currencyUomId, request);
- ProductConfigWorker.fillProductConfigWrapper(configWrapper, request);
+ configWrapper = ProductConfigWorker.getProductConfigWrapper(product.productId, currencyUomId, request)
+ ProductConfigWorker.fillProductConfigWrapper(configWrapper, request)
if (!configWrapper.isCompleted()) {
- configId = request.getParameter("configId");
+ configId = request.getParameter("configId")
if (configId) {
- configWrapper.loadConfig(delegator, configId);
+ configWrapper.loadConfig(delegator, configId)
} else {
- configWrapper.setDefaultConfig();
+ configWrapper.setDefaultConfig()
}
}
- ProductConfigWorker.storeProductConfigWrapper(configWrapper, delegator);
+ ProductConfigWorker.storeProductConfigWrapper(configWrapper, delegator)
if (!ProductStoreWorker.isStoreInventoryAvailable(request, configWrapper, 1.0)) {
- context.productNotAvailable = "Y";
+ context.productNotAvailable = "Y"
}
- context.configwrapper = configWrapper;
- context.configId = configWrapper.getConfigId();
- context.totalPrice = configWrapper.getTotalPrice();
- context.renderSingleChoiceWithRadioButtons = "Y";
- context.showOffsetPrice = "Y";
+ context.configwrapper = configWrapper
+ context.configId = configWrapper.getConfigId()
+ context.totalPrice = configWrapper.getTotalPrice()
+ context.renderSingleChoiceWithRadioButtons = "Y"
+ context.showOffsetPrice = "Y"
}
Modified: ofbiz/trunk/applications/order/groovyScripts/entry/catalog/Product.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/groovyScripts/entry/catalog/Product.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/groovyScripts/entry/catalog/Product.groovy (original)
+++ ofbiz/trunk/applications/order/groovyScripts/entry/catalog/Product.groovy Wed Nov 2 19:09:13 2016
@@ -17,129 +17,129 @@
* under the License.
*/
-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 org.apache.ofbiz.product.category.*;
-import org.apache.ofbiz.product.product.ProductWorker;
-import org.apache.ofbiz.product.product.ProductContentWrapper;
-import org.apache.ofbiz.entity.util.EntityUtil;
-
-contentPathPrefix = CatalogWorker.getContentPathPrefix(request);
-catalogName = CatalogWorker.getCatalogName(request);
-currentCatalogId = CatalogWorker.getCurrentCatalogId(request);
-requestParams = UtilHttp.getParameterMap(request);
-
-detailScreen = "productdetail";
-productId = requestParams.product_id ?: request.getAttribute("product_id");
-
-pageTitle = null;
-metaDescription = null;
-metaKeywords = null;
+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 org.apache.ofbiz.product.category.*
+import org.apache.ofbiz.product.product.ProductWorker
+import org.apache.ofbiz.product.product.ProductContentWrapper
+import org.apache.ofbiz.entity.util.EntityUtil
+
+contentPathPrefix = CatalogWorker.getContentPathPrefix(request)
+catalogName = CatalogWorker.getCatalogName(request)
+currentCatalogId = CatalogWorker.getCurrentCatalogId(request)
+requestParams = UtilHttp.getParameterMap(request)
+
+detailScreen = "productdetail"
+productId = requestParams.product_id ?: request.getAttribute("product_id")
+
+pageTitle = null
+metaDescription = null
+metaKeywords = null
// get the product entity
if (productId) {
- product = from("Product").where("productId", productId).cache(true).queryOne();
+ product = from("Product").where("productId", productId).cache(true).queryOne()
if (product) {
// first make sure this isn't a virtual-variant that has an associated virtual product, if it does show that instead of the variant
if("Y".equals(product.isVirtual) && "Y".equals(product.isVariant)){
- virtualVariantProductAssocs = from("ProductAssoc").where("productId", productId, "productAssocTypeId", "ALTERNATIVE_PACKAGE").orderBy("-fromDate").filterByDate().cache(true).queryList();
+ virtualVariantProductAssocs = from("ProductAssoc").where("productId", productId, "productAssocTypeId", "ALTERNATIVE_PACKAGE").orderBy("-fromDate").filterByDate().cache(true).queryList()
if (virtualVariantProductAssocs) {
- productAssoc = EntityUtil.getFirst(virtualVariantProductAssocs);
- product = productAssoc.getRelatedOne("AssocProduct", true);
+ productAssoc = EntityUtil.getFirst(virtualVariantProductAssocs)
+ product = productAssoc.getRelatedOne("AssocProduct", true)
}
}
}
// first make sure this isn't a variant that has an associated virtual product, if it does show that instead of the variant
- virtualProductId = ProductWorker.getVariantVirtualId(product);
+ virtualProductId = ProductWorker.getVariantVirtualId(product)
if (virtualProductId) {
- productId = virtualProductId;
- product = from("Product").where("productId", productId).cache(true).queryOne();
+ productId = virtualProductId
+ product = from("Product").where("productId", productId).cache(true).queryOne()
}
- productPageTitle = from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", "PAGE_TITLE").cache(true).queryList();
+ productPageTitle = from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", "PAGE_TITLE").cache(true).queryList()
if (productPageTitle) {
- pageTitle = from("ElectronicText").where("dataResourceId", productPageTitle.get(0).dataResourceId).cache(true).queryOne();
+ pageTitle = from("ElectronicText").where("dataResourceId", productPageTitle.get(0).dataResourceId).cache(true).queryOne()
}
- productMetaDescription = from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", "META_DESCRIPTION").cache(true).queryList();
+ productMetaDescription = from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", "META_DESCRIPTION").cache(true).queryList()
if (productMetaDescription) {
- metaDescription = from("ElectronicText").where("dataResourceId", productMetaDescription.get(0).dataResourceId).cache(true).queryOne();
+ metaDescription = from("ElectronicText").where("dataResourceId", productMetaDescription.get(0).dataResourceId).cache(true).queryOne()
}
- productMetaKeywords = from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", "META_KEYWORD").cache(true).queryList();
+ productMetaKeywords = from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", "META_KEYWORD").cache(true).queryList()
if (productMetaKeywords) {
- metaKeywords = from("ElectronicText").where("dataResourceId", productMetaKeywords.get(0).dataResourceId).cache(true).queryOne();
+ metaKeywords = from("ElectronicText").where("dataResourceId", productMetaKeywords.get(0).dataResourceId).cache(true).queryOne()
}
- context.productId = productId;
+ context.productId = productId
// now check to see if there is a view allow category and if this product is in it...
if (product) {
- viewProductCategoryId = CatalogWorker.getCatalogViewAllowCategoryId(delegator, currentCatalogId);
+ viewProductCategoryId = CatalogWorker.getCatalogViewAllowCategoryId(delegator, currentCatalogId)
if (viewProductCategoryId) {
if (!CategoryWorker.isProductInCategory(delegator, productId, viewProductCategoryId)) {
// a view allow productCategoryId was found, but the product is not in the category, axe it...
- product = null;
+ product = null
}
}
}
if (product) {
- context.product = product;
- contentWrapper = new ProductContentWrapper(product, request);
+ context.product = product
+ contentWrapper = new ProductContentWrapper(product, request)
if (pageTitle) {
- context.title = pageTitle.textData;
+ context.title = pageTitle.textData
} else {
- context.put("title", contentWrapper.get("PRODUCT_NAME", "html"));
+ context.put("title", contentWrapper.get("PRODUCT_NAME", "html"))
}
if (metaDescription) {
- context.metaDescription = metaDescription.textData;
+ context.metaDescription = metaDescription.textData
} else {
- context.put("metaDescription", contentWrapper.get("DESCRIPTION", "html"));
+ context.put("metaDescription", contentWrapper.get("DESCRIPTION", "html"))
}
if (metaKeywords) {
- context.metaKeywords = metaKeywords.textData;
+ context.metaKeywords = metaKeywords.textData
} else {
- keywords = [];
- keywords.add(contentWrapper.get("PRODUCT_NAME", "html"));
- keywords.add(catalogName);
- members = from("ProductCategoryMember").where("productId", productId).cache(true).queryList();
+ keywords = []
+ keywords.add(contentWrapper.get("PRODUCT_NAME", "html"))
+ keywords.add(catalogName)
+ members = from("ProductCategoryMember").where("productId", productId).cache(true).queryList()
members.each { member ->
- category = member.getRelatedOne("ProductCategory", true);
+ category = member.getRelatedOne("ProductCategory", true)
if (category.description) {
- categoryContentWrapper = new CategoryContentWrapper(category, request);
- categoryDescription = categoryContentWrapper.get("DESCRIPTION", "html");
+ categoryContentWrapper = new CategoryContentWrapper(category, request)
+ categoryDescription = categoryContentWrapper.get("DESCRIPTION", "html")
if (categoryDescription) {
- keywords.add(categoryDescription);
+ keywords.add(categoryDescription)
}
}
}
- context.metaKeywords = StringUtil.join(keywords, ", ");
+ context.metaKeywords = StringUtil.join(keywords, ", ")
}
// Set the default template for aggregated product (product component configurator ui)
if (product.productTypeId && ("AGGREGATED".equals(product.productTypeId) || "AGGREGATED_SERVICE".equals(product.productTypeId)) && context.configproductdetailScreen) {
- detailScreen = context.configproductdetailScreen;
+ detailScreen = context.configproductdetailScreen
}
- productTemplate = product.detailScreen;
+ productTemplate = product.detailScreen
if (productTemplate) {
- detailScreen = productTemplate;
+ detailScreen = productTemplate
}
}
}
// check the catalog's template path and update
-templatePathPrefix = CatalogWorker.getTemplatePathPrefix(request);
+templatePathPrefix = CatalogWorker.getTemplatePathPrefix(request)
if (templatePathPrefix) {
- detailScreen = templatePathPrefix + detailScreen;
+ detailScreen = templatePathPrefix + detailScreen
}
// set the template for the view
-context.detailScreen = detailScreen;
+context.detailScreen = detailScreen