📄 catalogworker.java
字号:
try {
GenericValue prodCatalog = delegator.findByPrimaryKeyCache("ProdCatalog", UtilMisc.toMap("prodCatalogId", prodCatalogId));
if (prodCatalog != null) {
return prodCatalog.getString("catalogName");
}
} catch (GenericEntityException e) {
Debug.logError(e, "Error looking up name for prodCatalog with id " + prodCatalogId, module);
}
return null;
}
public static String getContentPathPrefix(ServletRequest request) {
GenericValue prodCatalog = getProdCatalog(request, getCurrentCatalogId(request));
if (prodCatalog == null) return "";
String contentPathPrefix = prodCatalog.getString("contentPathPrefix");
return StringUtil.cleanUpPathPrefix(contentPathPrefix);
}
public static String getTemplatePathPrefix(ServletRequest request) {
GenericValue prodCatalog = getProdCatalog(request, getCurrentCatalogId(request));
if (prodCatalog == null) return "";
String templatePathPrefix = prodCatalog.getString("templatePathPrefix");
return StringUtil.cleanUpPathPrefix(templatePathPrefix);
}
public static GenericValue getProdCatalog(ServletRequest request) {
return getProdCatalog(request, getCurrentCatalogId(request));
}
public static GenericValue getProdCatalog(ServletRequest request, String prodCatalogId) {
if (prodCatalogId == null || prodCatalogId.length() <= 0) return null;
GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
try {
return delegator.findByPrimaryKeyCache("ProdCatalog", UtilMisc.toMap("prodCatalogId", prodCatalogId));
} catch (GenericEntityException e) {
Debug.logError(e, "Error looking up name for prodCatalog with id " + prodCatalogId, module);
return null;
}
}
public static String getCatalogTopCategoryId(ServletRequest request) {
return getCatalogTopCategoryId(request, getCurrentCatalogId(request));
}
public static String getCatalogTopCategoryId(ServletRequest request, String prodCatalogId) {
if (prodCatalogId == null || prodCatalogId.length() <= 0) return null;
List prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_BROWSE_ROOT");
if (prodCatalogCategories != null && prodCatalogCategories.size() > 0) {
GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories);
return prodCatalogCategory.getString("productCategoryId");
} else {
return null;
}
}
public static String getCatalogSearchCategoryId(ServletRequest request) {
return getCatalogSearchCategoryId(request, getCurrentCatalogId(request));
}
public static String getCatalogSearchCategoryId(ServletRequest request, String prodCatalogId) {
return getCatalogSearchCategoryId((GenericDelegator) request.getAttribute("delegator"), prodCatalogId);
}
public static String getCatalogSearchCategoryId(GenericDelegator delegator, String prodCatalogId) {
if (prodCatalogId == null || prodCatalogId.length() <= 0) return null;
List prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_SEARCH");
if (prodCatalogCategories != null && prodCatalogCategories.size() > 0) {
GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories);
return prodCatalogCategory.getString("productCategoryId");
} else {
return null;
}
}
public static String getCatalogViewAllowCategoryId(GenericDelegator delegator, String prodCatalogId) {
if (prodCatalogId == null || prodCatalogId.length() <= 0) return null;
List prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_VIEW_ALLW");
if (prodCatalogCategories != null && prodCatalogCategories.size() > 0) {
GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories);
return prodCatalogCategory.getString("productCategoryId");
} else {
return null;
}
}
public static String getCatalogPurchaseAllowCategoryId(GenericDelegator delegator, String prodCatalogId) {
if (prodCatalogId == null || prodCatalogId.length() <= 0) return null;
List prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_PURCH_ALLW");
if (prodCatalogCategories != null && prodCatalogCategories.size() > 0) {
GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories);
return prodCatalogCategory.getString("productCategoryId");
} else {
return null;
}
}
public static String getCatalogPromotionsCategoryId(ServletRequest request) {
return getCatalogPromotionsCategoryId(request, getCurrentCatalogId(request));
}
public static String getCatalogPromotionsCategoryId(ServletRequest request, String prodCatalogId) {
if (prodCatalogId == null || prodCatalogId.length() <= 0) return null;
List prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_PROMOTIONS");
if (prodCatalogCategories != null && prodCatalogCategories.size() > 0) {
GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories);
return prodCatalogCategory.getString("productCategoryId");
} else {
return null;
}
}
public static boolean getCatalogQuickaddUse(ServletRequest request) {
return getCatalogQuickaddUse(request, getCurrentCatalogId(request));
}
public static boolean getCatalogQuickaddUse(ServletRequest request, String prodCatalogId) {
if (prodCatalogId == null || prodCatalogId.length() <= 0) return false;
GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
try {
GenericValue prodCatalog = delegator.findByPrimaryKeyCache("ProdCatalog", UtilMisc.toMap("prodCatalogId", prodCatalogId));
if (prodCatalog != null) {
return "Y".equals(prodCatalog.getString("useQuickAdd"));
}
} catch (GenericEntityException e) {
Debug.logError(e, "Error looking up name for prodCatalog with id " + prodCatalogId, module);
}
return false;
}
public static String getCatalogQuickaddCategoryPrimary(ServletRequest request) {
return getCatalogQuickaddCategoryPrimary(request, getCurrentCatalogId(request));
}
public static String getCatalogQuickaddCategoryPrimary(ServletRequest request, String prodCatalogId) {
if (prodCatalogId == null || prodCatalogId.length() <= 0) return null;
List prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_QUICK_ADD");
if (prodCatalogCategories != null && prodCatalogCategories.size() > 0) {
GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories);
return prodCatalogCategory.getString("productCategoryId");
} else {
return null;
}
}
public static Collection getCatalogQuickaddCategories(ServletRequest request) {
return getCatalogQuickaddCategories(request, getCurrentCatalogId(request));
}
public static Collection getCatalogQuickaddCategories(ServletRequest request, String prodCatalogId) {
if (prodCatalogId == null || prodCatalogId.length() <= 0) return null;
Collection categoryIds = new LinkedList();
Collection prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_QUICK_ADD");
if (prodCatalogCategories != null && prodCatalogCategories.size() > 0) {
Iterator pccIter = prodCatalogCategories.iterator();
while (pccIter.hasNext()) {
GenericValue prodCatalogCategory = (GenericValue) pccIter.next();
categoryIds.add(prodCatalogCategory.getString("productCategoryId"));
}
}
return categoryIds;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -