本文整理汇总了Java中org.ofbiz.product.product.ProductWorker.getVariantVirtualAssocs方法的典型用法代码示例。如果您正苦于以下问题:Java ProductWorker.getVariantVirtualAssocs方法的具体用法?Java ProductWorker.getVariantVirtualAssocs怎么用?Java ProductWorker.getVariantVirtualAssocs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ofbiz.product.product.ProductWorker
的用法示例。
在下文中一共展示了ProductWorker.getVariantVirtualAssocs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isProductInCategory
import org.ofbiz.product.product.ProductWorker; //导入方法依赖的package包/类
public static boolean isProductInCategory(Delegator delegator, String productId, String productCategoryId) throws GenericEntityException {
if (productCategoryId == null) return false;
if (UtilValidate.isEmpty(productId)) return false;
List<GenericValue> productCategoryMembers = EntityUtil.filterByDate(delegator.findByAnd("ProductCategoryMember",
UtilMisc.toMap("productCategoryId", productCategoryId, "productId", productId), null, true), true);
if (UtilValidate.isEmpty(productCategoryMembers)) {
//before giving up see if this is a variant product, and if so look up the virtual product and check it...
GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true);
List<GenericValue> productAssocs = ProductWorker.getVariantVirtualAssocs(product);
//this does take into account that a product could be a variant of multiple products, but this shouldn't ever really happen...
if (productAssocs != null) {
for (GenericValue productAssoc: productAssocs) {
if (isProductInCategory(delegator, productAssoc.getString("productId"), productCategoryId)) {
return true;
}
}
}
return false;
} else {
return true;
}
}
示例2: isProductInCategory
import org.ofbiz.product.product.ProductWorker; //导入方法依赖的package包/类
public static boolean isProductInCategory(Delegator delegator, String productId, String productCategoryId) throws GenericEntityException {
if (productCategoryId == null)
return false;
if (UtilValidate.isEmpty(productId))
return false;
List<GenericValue> productCategoryMembers = EntityQuery.use(delegator).from("ProductCategoryMember")
.where("productCategoryId", productCategoryId, "productId", productId).cache(true).filterByDate().queryList();
if (UtilValidate.isEmpty(productCategoryMembers)) {
// before giving up see if this is a variant product, and if so look
// up the virtual product and check it...
GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne();
List<GenericValue> productAssocs = ProductWorker.getVariantVirtualAssocs(product);
// this does take into account that a product could be a variant of
// multiple products, but this shouldn't ever really happen...
if (productAssocs != null) {
for (GenericValue productAssoc : productAssocs) {
if (isProductInCategory(delegator, productAssoc.getString("productId"), productCategoryId)) {
return true;
}
}
}
return false;
} else {
return true;
}
}