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

📄 productdetail.bsh

📁 国外的一套开源CRM
💻 BSH
📖 第 1 页 / 共 2 页
字号:
/*
 *  Copyright (c) 2003 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    $Revision: 1.27 $
 *@since      2.1
 */

import org.ofbiz.base.util.*;
import org.ofbiz.entity.*;
import org.ofbiz.entity.util.*;
import org.ofbiz.service.*;
import org.ofbiz.content.webapp.taglib.*;
import org.ofbiz.product.product.ProductContentWrapper;
import org.ofbiz.product.catalog.*;
import org.ofbiz.product.store.*;

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();
}

dispatcher = request.getAttribute("dispatcher");
delegator = request.getAttribute("delegator");
userLogin = session.getAttribute("userLogin");
requestParams = UtilHttp.getParameterMap(request);

// get the shopping lists for the user (if logged in)
if (userLogin != null) {
    shoppingLists = delegator.findByAnd("ShoppingList", UtilMisc.toMap("partyId", userLogin.getString("partyId")), UtilMisc.toList("listName"));
    context.put("shoppingLists", shoppingLists);
}

// set the content path prefix
contentPathPrefix = CatalogWorker.getContentPathPrefix(request);
request.setAttribute("contentPathPrefix", contentPathPrefix);

// get the product detail information
product = request.getAttribute("product");
if (product != null) {
    productId = product.getString("productId");
    request.setAttribute("product_id", productId);
    productTypeId = product.getString("productTypeId");
    featureTypes = new HashMap();
    featureOrder = new LinkedList();

    // set this as a last viewed
    lastViewedProducts = session.getAttribute("lastViewedProducts");
    if (lastViewedProducts == null) {
        lastViewedProducts = new ArrayList();
    }
    if (lastViewedProducts.contains(productId)) {
        lastViewedProducts.remove(productId);
    }
    lastViewedProducts.add(0, productId);
    session.setAttribute("lastViewedProducts", lastViewedProducts);
    if (lastViewedProducts.size() > 10) {
        while (lastViewedProducts.size() > 10) {
            lastViewedProducts.remove(lastViewedProducts.size() - 1);
        }
    }

    // make the productContentWrapper
    ProductContentWrapper productContentWrapper = new ProductContentWrapper(product, request);
    request.setAttribute("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 = requestParams.get("category_id");
    if (categoryId == null) categoryId = product.getString("primaryProductCategoryId");
    if (categoryId != null) request.setAttribute("categoryId", categoryId);

    Map catNextPreviousResult = null;
    if (categoryId != null) {
        catNextPreviousResult = dispatcher.runSync("getPreviousNextProducts", UtilMisc.toMap("categoryId", categoryId, "productId", productId));
        if (catNextPreviousResult != null) {
            request.setAttribute("category", catNextPreviousResult.get("category"));
            request.setAttribute("previousProductId", catNextPreviousResult.get("previousProductId"));
            request.setAttribute("nextProductId", catNextPreviousResult.get("nextProductId"));
        }
    }

    // get a defined survey
    productStoreId = ProductStoreWorker.getProductStoreId(request);
    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);
        request.setAttribute("surveyWrapper", wrapper);
    }

    // get the product price
    catalogId = CatalogWorker.getCurrentCatalogId(request);
    webSiteId = CatalogWorker.getWebSiteId(request);
    currentCatalogId = CatalogWorker.getCurrentCatalogId(request);
    autoUserLogin = request.getSession().getAttribute("autoUserLogin");
    fieldMap = UtilMisc.toMap("product", product, "prodCatalogId", catalogId, "webSiteId", webSiteId,
        "currencyUomId", UtilHttp.getCurrencyUom(session), "autoUserLogin", autoUserLogin);
    priceMap = dispatcher.runSync("calculateProductPrice", fieldMap);
    request.setAttribute("priceMap", priceMap);

    // get the product review(s)
    reviews = product.getRelated("ProductReview", null, UtilMisc.toList("-postedDateTime"));
    request.setAttribute("productReviews", reviews);

    // get the days to ship
    productStore = ProductStoreWorker.getProductStore(request);
    productStoreId = productStore.getString("productStoreId");

⌨️ 快捷键说明

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