📄 editproductquickadmin.bsh
字号:
context.put("distinguishingFeatures", distinguishingFeatures); Iterator distinguishingFeatureIter = distinguishingFeatures.iterator(); while (distinguishingFeatureIter.hasNext()) { GenericValue distFeature = (GenericValue) distinguishingFeatureIter.next(); GenericValue featureType = distFeature.getRelatedOneCache("ProductFeatureType"); if (!productFeatureTypeLookup.containsKey(distFeature.getString("productFeatureId"))) { productFeatureTypeLookup.put(distFeature.getString("productFeatureId"), featureType); } } } context.put("productFeatureTypeLookup", productFeatureTypeLookup); // get shipping dimensions and weights for single product List prodFeaturesFiltered = null; prodFeaturesFiltered = EntityUtil.filterByAnd(productFeatureAndAppls, UtilMisc.toMap("productFeatureTypeId", "AMOUNT", "uomId", "VLIQ_ozUS")); if (prodFeaturesFiltered.size() > 0) { try { floz = ((GenericValue)prodFeaturesFiltered.get(0)).getDouble("numberSpecified"); } catch (Exception e) { floz = null; } context.put("floz", floz); } prodFeaturesFiltered = EntityUtil.filterByAnd(productFeatureAndAppls, UtilMisc.toMap("productFeatureTypeId", "AMOUNT", "uomId", "VLIQ_ml")); if (prodFeaturesFiltered.size() > 0) { try { ml = ((GenericValue)prodFeaturesFiltered.get(0)).getDouble("numberSpecified"); } catch (Exception e) { ml = null; } context.put("ml", ml); } prodFeaturesFiltered = EntityUtil.filterByAnd(productFeatureAndAppls, UtilMisc.toMap("productFeatureTypeId", "AMOUNT", "uomId", "WT_g")); if (prodFeaturesFiltered.size() > 0) { try { grams = ((GenericValue)prodFeaturesFiltered.get(0)).getDouble("numberSpecified"); } catch (Exception e) { grams = null; } context.put("grams", grams); } prodFeaturesFiltered = EntityUtil.filterByAnd(productFeatureAndAppls, UtilMisc.toMap("productFeatureTypeId", "AMOUNT", "uomId", "WT_oz")); if (prodFeaturesFiltered.size() > 0) { try { ntwt = ((GenericValue)prodFeaturesFiltered.get(0)).getDouble("numberSpecified"); } catch (Exception e) { ntwt = null; } context.put("ntwt", ntwt); } prodFeaturesFiltered = EntityUtil.filterByAnd(productFeatureAndAppls, UtilMisc.toMap("productFeatureTypeId", "HAZMAT")); if (prodFeaturesFiltered.size() > 0) { try { hazmat = ((GenericValue)prodFeaturesFiltered.get(0)).getString("description"); } catch (Exception e) { hazmat = "nbsp;"; } if (hazmat == null) { hazmat = "nbsp;"; } context.put("hazmat", hazmat); } java.sql.Timestamp salesThru = product.getTimestamp("salesDiscontinuationDate"); if (salesThru == null) { salesthru = "[ ]"; } else if (salesThru.after(new java.util.Date())) { salesthru = "<div style='color: blue'>[x]</div>"; } else { salesthru = "<div style='color: red'>[x]</div>"; } context.put("salesthru", salesthru); thrudate = ""; context.put("thrudate", thrudate); // get all variants - associations first Collection productAssocs = product.getRelatedByAnd("MainProductAssoc", UtilMisc.toMap("productAssocTypeId", "PRODUCT_VARIANT")); Iterator productAssocIter = productAssocs.iterator(); // get shipping dimensions and weights for all the variants while (productAssocIter.hasNext()) { // now get the variant product GenericValue productAssoc = (GenericValue)productAssocIter.next(); GenericValue assocProduct = productAssoc.getRelatedOne("AssocProduct"); if (assocProduct != null) { assocProducts.add(assocProduct); List assocProductFeatureAndAppls = assocProduct.getRelated("ProductFeatureAndAppl"); List prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, UtilMisc.toMap("productFeatureTypeId", "AMOUNT", "uomId", "VLIQ_ozUS")); if (prodFeaturesFiltered.size() > 0) { featureFloz.put(assocProduct.getString("productId"), ((GenericValue)prodFeaturesFiltered.get(0)).getDouble("numberSpecified")); } prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, UtilMisc.toMap("productFeatureTypeId", "AMOUNT", "uomId", "VLIQ_ml")); if (prodFeaturesFiltered.size() > 0) { featureMl.put(assocProduct.getString("productId"), ((GenericValue)prodFeaturesFiltered.get(0)).getDouble("numberSpecified")); } prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, UtilMisc.toMap("productFeatureTypeId", "AMOUNT", "uomId", "WT_g")); if (prodFeaturesFiltered.size() > 0) { featureGrams.put(assocProduct.getString("productId"), ((GenericValue)prodFeaturesFiltered.get(0)).getDouble("numberSpecified")); } prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, UtilMisc.toMap("productFeatureTypeId", "AMOUNT", "uomId", "WT_oz")); if (prodFeaturesFiltered.size() > 0) { featureNtwt.put(assocProduct.getString("productId"), ((GenericValue)prodFeaturesFiltered.get(0)).getDouble("numberSpecified")); } prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, UtilMisc.toMap("productFeatureTypeId", "HAZMAT")); if (prodFeaturesFiltered.size() > 0) { featureHazmat.put(assocProduct.getString("productId"), ((GenericValue)prodFeaturesFiltered.get(0)).getString("description")); } else { featureHazmat.put(assocProduct.getString("productId"), " "); } java.sql.Timestamp salesThru = assocProduct.getTimestamp("salesDiscontinuationDate"); if (salesThru == null) { featureSalesThru.put(assocProduct.getString("productId"), "<div style='color: blue'>[ ]</div>"); } else if (salesThru.after(new java.util.Date())) { featureSalesThru.put(assocProduct.getString("productId"), "<div style='color: blue'>[x]</div>"); } else { featureSalesThru.put(assocProduct.getString("productId"), "<div style='color: red'>[x]</div>"); } java.sql.Timestamp thruDate = productAssoc.getTimestamp("thruDate"); if (thruDate == null) { featureThruDate.put(assocProduct.getString("productId"), "<div style='color: blue'>[ ]</div>"); } else if (thruDate.after(new java.util.Date())) { featureThruDate.put(assocProduct.getString("productId"), "<div style='color: blue'>[x]</div>"); } else { featureThruDate.put(assocProduct.getString("productId"), "<div style='color: red'>[x]</div>"); } prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, UtilMisc.toMap("productFeatureTypeId", productFeatureTypeId)); if (prodFeaturesFiltered.size() > 0) { // this is used for the selectable feature descriptions section; only include here iff the description is also associated with the virtual product as a selectable feature, ie if this is a distinguishing feature String curSelDescription = ((GenericValue) prodFeaturesFiltered.get(0)).getString("description"); testProductFeatureAndAppls = EntityUtil.filterByAnd(productFeatureAndAppls, UtilMisc.toMap("productFeatureTypeId", productFeatureTypeId, "description", curSelDescription, "productFeatureApplTypeId", "SELECTABLE_FEATURE")); if (testProductFeatureAndAppls.size() > 0) { selFeatureDesc.put(assocProduct.getString("productId"), curSelDescription); } } } } assocProducts = EntityUtil.orderBy(assocProducts, UtilMisc.toList("internalName")); context.put("assocProducts", assocProducts); context.put("productAssocs", productAssocs);}context.put("featureFloz", featureFloz);context.put("featureMl", featureMl);context.put("featureNtwt", featureNtwt);context.put("featureGrams", featureGrams);context.put("featureHazmat", featureHazmat);context.put("featureSalesThru", featureSalesThru);context.put("featureThruDate", featureThruDate);context.put("selFeatureDesc", selFeatureDesc);// get "all" category idString allCategoryId = UtilProperties.getPropertyValue("catalog", "all.product.category");context.put("allCategoryId", allCategoryId);// show the publish or unpublish sectionList prodCatMembs = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productCategoryId", allCategoryId, "productId", productId));//don't filter by date, show all categories: prodCatMembs = EntityUtil.filterByDate(prodCatMembs);String showPublish = "false";if (prodCatMembs.size() == 0) { showPublish = "true";}context.put("showPublish", showPublish);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -