use of org.broadleafcommerce.core.inventory.service.type.InventoryType in project BroadleafCommerce by BroadleafCommerce.
the class InventoryServiceImpl method retrieveQuantitiesAvailable.
@Override
public Map<Sku, Integer> retrieveQuantitiesAvailable(Collection<Sku> skus, Map<String, Object> context) {
ExtensionResultHolder<Map<Sku, Integer>> holder = new ExtensionResultHolder<Map<Sku, Integer>>();
ExtensionResultStatusType res = extensionManager.getProxy().retrieveQuantitiesAvailable(skus, context, holder);
if (ExtensionResultStatusType.NOT_HANDLED.equals(res)) {
Map<Sku, Integer> inventories = new HashMap<>();
for (Sku sku : skus) {
Integer quantityAvailable = 0;
if (checkBasicAvailablility(sku)) {
InventoryType skuInventoryType = sku.getInventoryType();
if (InventoryType.CHECK_QUANTITY.equals(skuInventoryType)) {
if (sku.getQuantityAvailable() != null) {
quantityAvailable = sku.getQuantityAvailable();
}
} else if (sku.getInventoryType() == null || InventoryType.ALWAYS_AVAILABLE.equals(skuInventoryType)) {
quantityAvailable = null;
}
}
inventories.put(sku, quantityAvailable);
}
return inventories;
} else {
return holder.getResult();
}
}
Aggregations