本文整理匯總了Java中org.ofbiz.product.config.ProductConfigWrapper.getSelectedOptions方法的典型用法代碼示例。如果您正苦於以下問題:Java ProductConfigWrapper.getSelectedOptions方法的具體用法?Java ProductConfigWrapper.getSelectedOptions怎麽用?Java ProductConfigWrapper.getSelectedOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.ofbiz.product.config.ProductConfigWrapper
的用法示例。
在下文中一共展示了ProductConfigWrapper.getSelectedOptions方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isProductInventoryAvailableByFacility
import org.ofbiz.product.config.ProductConfigWrapper; //導入方法依賴的package包/類
/**
* Invokes the getInventoryAvailableByFacility service, returns true if specified quantity is available for all the selected parts, else false.
* Also, set the available flag for all the product configuration's options.
**/
public static boolean isProductInventoryAvailableByFacility(ProductConfigWrapper productConfig, String inventoryFacilityId, BigDecimal quantity, LocalDispatcher dispatcher) {
boolean available = true;
List<ConfigOption> options = productConfig.getSelectedOptions();
for (ConfigOption ci: options) {
List<GenericValue> products = ci.getComponents();
for (GenericValue product: products) {
String productId = product.getString("productId");
BigDecimal cmpQuantity = product.getBigDecimal("quantity");
BigDecimal neededQty = BigDecimal.ZERO;
if (cmpQuantity != null) {
neededQty = quantity.multiply(cmpQuantity);
}
if (!isProductInventoryAvailableByFacility(productId, inventoryFacilityId, neededQty, dispatcher)) {
ci.setAvailable(false);
}
}
if (!ci.isAvailable()) {
available = false;
}
}
return available;
}