本文整理匯總了Java中org.ofbiz.product.category.CategoryWorker.isProductInCategory方法的典型用法代碼示例。如果您正苦於以下問題:Java CategoryWorker.isProductInCategory方法的具體用法?Java CategoryWorker.isProductInCategory怎麽用?Java CategoryWorker.isProductInCategory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.ofbiz.product.category.CategoryWorker
的用法示例。
在下文中一共展示了CategoryWorker.isProductInCategory方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findProduct
import org.ofbiz.product.category.CategoryWorker; //導入方法依賴的package包/類
public static GenericValue findProduct(Delegator delegator, boolean skipProductChecks, String prodCatalogId, String productId, Locale locale) throws CartItemModifyException, ItemNotFoundException {
GenericValue product;
try {
product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne();
// first see if there is a purchase allow category and if this product is in it or not
String purchaseProductCategoryId = CatalogWorker.getCatalogPurchaseAllowCategoryId(delegator, prodCatalogId);
if (!skipProductChecks && product != null && purchaseProductCategoryId != null) {
if (!CategoryWorker.isProductInCategory(delegator, product.getString("productId"), purchaseProductCategoryId)) {
// a Purchase allow productCategoryId was found, but the product is not in the category, axe it...
Debug.logWarning("Product [" + productId + "] is not in the purchase allow category [" + purchaseProductCategoryId + "] and cannot be purchased", module);
product = null;
}
}
} catch (GenericEntityException e) {
Debug.logWarning(e.toString(), module);
product = null;
}
if (product == null) {
Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("productId", productId);
String excMsg = UtilProperties.getMessage(resource_error, "item.product_not_found", messageMap , locale);
Debug.logWarning(excMsg, module);
throw new ItemNotFoundException(excMsg);
}
return product;
}
示例2: findAllCartItemsInCategory
import org.ofbiz.product.category.CategoryWorker; //導入方法依賴的package包/類
/** Get all ShoppingCartItems from the cart object with the given productCategoryId and optional groupNumber to limit it to a specific item group */
public List<ShoppingCartItem> findAllCartItemsInCategory(String productCategoryId, String groupNumber) {
if (productCategoryId == null) return this.items();
Delegator delegator = this.getDelegator();
List<ShoppingCartItem> itemsToReturn = FastList.newInstance();
try {
// Check for existing cart item
for (ShoppingCartItem cartItem : cartLines) {
//Debug.logInfo("Checking cartItem with product [" + cartItem.getProductId() + "] becuase that is in group [" + (cartItem.getItemGroup()==null ? "no group" : cartItem.getItemGroup().getGroupNumber()) + "]", module);
if (UtilValidate.isNotEmpty(groupNumber) && !cartItem.isInItemGroup(groupNumber)) {
//Debug.logInfo("Not using cartItem with product [" + cartItem.getProductId() + "] becuase not in group [" + groupNumber + "]", module);
continue;
}
if (CategoryWorker.isProductInCategory(delegator, cartItem.getProductId(), productCategoryId)) {
itemsToReturn.add(cartItem);
} else {
//Debug.logInfo("Not using cartItem with product [" + cartItem.getProductId() + "] becuase not in category [" + productCategoryId + "]", module);
}
}
} catch (GenericEntityException e) {
Debug.logError(e, "Error getting cart items that are in a category: " + e.toString(), module);
}
//Debug.logInfo("Got [" + itemsToReturn.size() + "] cart items in category [" + productCategoryId + "] and item group [" + groupNumber + "]", module);
return itemsToReturn;
}
示例3: findProduct
import org.ofbiz.product.category.CategoryWorker; //導入方法依賴的package包/類
public static GenericValue findProduct(Delegator delegator, boolean skipProductChecks, String prodCatalogId, String productId, Locale locale) throws CartItemModifyException, ItemNotFoundException {
GenericValue product;
try {
product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true);
// first see if there is a purchase allow category and if this product is in it or not
String purchaseProductCategoryId = CatalogWorker.getCatalogPurchaseAllowCategoryId(delegator, prodCatalogId);
if (!skipProductChecks && product != null && purchaseProductCategoryId != null) {
if (!CategoryWorker.isProductInCategory(delegator, product.getString("productId"), purchaseProductCategoryId)) {
// a Purchase allow productCategoryId was found, but the product is not in the category, axe it...
Debug.logWarning("Product [" + productId + "] is not in the purchase allow category [" + purchaseProductCategoryId + "] and cannot be purchased", module);
product = null;
}
}
} catch (GenericEntityException e) {
Debug.logWarning(e.toString(), module);
product = null;
}
if (product == null) {
Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("productId", productId);
String excMsg = UtilProperties.getMessage(resource_error, "item.product_not_found", messageMap , locale);
Debug.logWarning(excMsg, module);
throw new ItemNotFoundException(excMsg);
}
return product;
}