⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 productdetail.bsh

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 BSH
📖 第 1 页 / 共 2 页
字号:
/* *  Copyright (c) 2003-2006 The Open For Business Project - www.ofbiz.org * *  Permission is hereby granted, free of charge, to any person obtaining a  *  copy of this software and associated documentation files (the "Software"),  *  to deal in the Software without restriction, including without limitation  *  the rights to use, copy, modify, merge, publish, distribute, sublicense,  *  and/or sell copies of the Software, and to permit persons to whom the  *  Software is furnished to do so, subject to the following conditions: * *  The above copyright notice and this permission notice shall be included  *  in all copies or substantial portions of the Software. * *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT  *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR  *  THE USE OR OTHER DEALINGS IN THE SOFTWARE. * *@author     Andy Zeneski *@author     David E. Jones *@version    $Rev: 6948 $ *@since      2.1*//* * This script is also referenced by the ecommerce's screens and * should not contain order component's specific code. */import org.ofbiz.base.util.*;import org.ofbiz.entity.*;import org.ofbiz.entity.condition.*;import org.ofbiz.entity.util.*;import org.ofbiz.service.*;import org.ofbiz.webapp.taglib.*;import org.ofbiz.product.product.ProductContentWrapper;import org.ofbiz.product.product.ProductSearch;import org.ofbiz.product.product.ProductSearchSession;import org.ofbiz.product.product.ProductWorker;import org.ofbiz.product.catalog.*;import org.ofbiz.product.store.*;import org.ofbiz.webapp.stats.VisitHandler;import org.ofbiz.order.shoppingcart.ShoppingCartEvents;String buildNext(Map map, List order, String current, String prefix, Map featureTypes) {    keySet = map.keySet();    ct = 0;    i = keySet.iterator();    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.get(current) + "\",\"\",true,true);");    while (i.hasNext()) {        key = i.next();        value = map.get(key);        optValue = null;        if (order.indexOf(current) == (order.size()-1)) {            optValue = value.iterator().next();        } else {            optValue = prefix + "_" + ct;        }        buf.append("document.forms[\"addform\"].elements[\"FT" + current + "\"].options[" + (ct + 1) + "] = new Option(\"" + key + "\",\"" + optValue + "\");");        ct++;    }    buf.append(" }");    if (order.indexOf(current) < (order.size()-1)) {        i2 = keySet.iterator();        ct = 0;        while (i2.hasNext()) {            nextOrder = order.get(order.indexOf(current)+1);            key = i2.next();            value = map.get(key);            newPrefix = prefix + "_" + ct;            buf.append(buildNext(value, order, nextOrder, newPrefix, featureTypes));            ct++;        }    }    return buf.toString();}cart = ShoppingCartEvents.getCartObject(request);// get the shopping lists for the user (if logged in)if (userLogin != null) {    exprList = UtilMisc.toList(new EntityExpr("partyId", EntityOperator.EQUALS, userLogin.getString("partyId")),        new EntityExpr("listName", EntityOperator.NOT_EQUAL, "auto-save"));    condition = new EntityConditionList(exprList, EntityOperator.AND);    allShoppingLists = delegator.findByCondition("ShoppingList", condition, null, UtilMisc.toList("listName"));            context.put("shoppingLists", allShoppingLists);}// set the content path prefixcontentPathPrefix = CatalogWorker.getContentPathPrefix(request);context.put("contentPathPrefix", contentPathPrefix);// get the product detail informationif (product != null) {    productId = product.getString("productId");    context.put("product_id", productId);    productTypeId = product.getString("productTypeId");    featureTypes = new HashMap();    featureOrder = new LinkedList();    // set this as a last viewed    int LAST_VIEWED_TO_KEEP = 10; // modify this to change the number of last viewed to keep    lastViewedProducts = session.getAttribute("lastViewedProducts");    if (lastViewedProducts == null) {        lastViewedProducts = new LinkedList();        session.setAttribute("lastViewedProducts", lastViewedProducts);    }    lastViewedProducts.remove(productId);    lastViewedProducts.add(0, productId);    while (lastViewedProducts.size() > LAST_VIEWED_TO_KEEP) {         lastViewedProducts.remove(lastViewedProducts.size() - 1);    }    // make the productContentWrapper    ProductContentWrapper productContentWrapper = new ProductContentWrapper(product, request);    context.put("productContentWrapper", productContentWrapper);    // get the main detail image (virtual or single product)    mainDetailImage = productContentWrapper.get("DETAIL_IMAGE_URL");    if (mainDetailImage != null && mainDetailImage.length() > 0) {        mainDetailImageUrl = ContentUrlTag.getContentPrefix(request) + mainDetailImage;        mainDetailImageUrl = URLEncoder.encode(Base64.base64Encode(mainDetailImage), "UTF-8");        context.put("mainDetailImageUrl", mainDetailImageUrl);    }    // get next/previous information for category    categoryId = parameters.get("category_id");    if (categoryId == null) categoryId = product.getString("primaryProductCategoryId");    if (categoryId != null) context.put("categoryId", categoryId);    Map catNextPreviousResult = null;    if (!UtilValidate.isEmpty(categoryId)) {        catNextPreviousResult = dispatcher.runSync("getPreviousNextProducts", UtilMisc.toMap("categoryId", categoryId, "productId", productId));        if (ServiceUtil.isError(catNextPreviousResult)) {            request.setAttribute("errorMessageList", UtilMisc.toList(ServiceUtil.getErrorMessage(catNextPreviousResult)));            return;        }        if (catNextPreviousResult != null && catNextPreviousResult.get("category") != null) {            context.put("category", catNextPreviousResult.get("category"));            context.put("previousProductId", catNextPreviousResult.get("previousProductId"));            context.put("nextProductId", catNextPreviousResult.get("nextProductId"));        }    }    // get the product store    productStore = ProductStoreWorker.getProductStore(request);    productStoreId = productStore.getString("productStoreId");        context.put("productStoreId", productStoreId);    // get a defined survey    productSurvey = ProductStoreWorker.getProductSurveys(delegator, productStoreId, productId, "CART_ADD");    if (productSurvey != null && productSurvey.size() > 0) {        survey = EntityUtil.getFirst(productSurvey);        surveyContext = UtilHttp.getParameterMap(request);        surveyPartyId = null;        if (userLogin != null) {            surveyPartyId = userLogin.getString("partyId");        }        ProductStoreSurveyWrapper wrapper = new ProductStoreSurveyWrapper(survey, surveyPartyId, surveyContext);        context.put("surveyWrapper", wrapper);    }    // get the product price    catalogId = CatalogWorker.getCurrentCatalogId(request);    currentCatalogId = catalogId;    webSiteId = CatalogWorker.getWebSiteId(request);    autoUserLogin = request.getSession().getAttribute("autoUserLogin");    if (cart.isSalesOrder()) {        // sales order: run the "calculateProductPrice" service        priceContext = UtilMisc.toMap("product", product, "prodCatalogId", catalogId,            "currencyUomId", cart.getCurrency(), "autoUserLogin", autoUserLogin);        priceContext.put("webSiteId", webSiteId);        priceContext.put("productStoreId", productStoreId);        priceContext.put("checkIncludeVat", "Y");        priceMap = dispatcher.runSync("calculateProductPrice", priceContext);        context.put("priceMap", priceMap);    } else {        // purchase order: run the "calculatePurchasePrice" service        priceContext = UtilMisc.toMap("product", product, "currencyUomId", cart.getCurrency(),                 "partyId", cart.getPartyId(), "userLogin", userLogin);        priceMap = dispatcher.runSync("calculatePurchasePrice", priceContext);        context.put("priceMap", priceMap);    }    // get the product review(s)    reviewByAnd = UtilMisc.toMap("statusId", "PRR_APPROVED", "productStoreId", productStoreId);    reviews = product.getRelatedCache("ProductReview", reviewByAnd, UtilMisc.toList("-postedDateTime"));    context.put("productReviews", reviews);    // get the average rating    if (reviews != null && reviews.size() > 0) {        List ratingReviews = EntityUtil.filterByAnd(reviews, UtilMisc.toList(new EntityExpr("productRating", EntityOperator.NOT_EQUAL, null)));        if (ratingReviews.size() > 0) {            context.put("averageRating", ProductWorker.getAverageProductRating(product, reviews, productStoreId));            context.put("numRatings", ratingReviews.size());        }    }    // get the days to ship    facilityId = productStore.getString("inventoryFacilityId");    productFacility = delegator.findByPrimaryKeyCache("ProductFacility", UtilMisc.toMap("productId", productId, "facilityId", facilityId));    if (productFacility != null && productFacility.get("daysToShip") != null) {        context.put("daysToShip", productFacility.get("daysToShip"));    }    // get the product distinguishing features    disFeatureMap = dispatcher.runSync("getProductFeatures", UtilMisc.toMap("productId", productId, "type", "DISTINGUISHING_FEAT"));    disFeatureList = disFeatureMap.get("productFeatures");    context.put("disFeatureList", disFeatureList);        // an example of getting features of a certain type to show    sizeProductFeatureAndAppls = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureTypeId", "SIZE"), UtilMisc.toList("sequenceNum", "defaultSequenceNum"));    context.put("sizeProductFeatureAndAppls", sizeProductFeatureAndAppls);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -