Package org.apache.ofbiz.product.product
Class ProductWorker
java.lang.Object
org.apache.ofbiz.product.product.ProductWorker
Product Worker class to reduce code in JSPs.
-
Method Summary
Modifier and TypeMethodDescriptionstatic BigDecimal
calcOrderAdjustment
(GenericValue orderAdjustment, BigDecimal orderSubTotal) static BigDecimal
calcOrderAdjustments
(List<GenericValue> orderHeaderAdjustments, BigDecimal subTotal, boolean includeOther, boolean includeTax, boolean includeShipping) static List<GenericValue>
filterOrderAdjustments
(List<GenericValue> adjustments, boolean includeOther, boolean includeTax, boolean includeShipping, boolean forTax, boolean forShipping) static List<GenericValue>
filterOutOfStockProducts
(List<GenericValue> productsToFilter, LocalDispatcher dispatcher, Delegator delegator) static GenericValue
findProduct
(Delegator delegator, String idToFind) static GenericValue
findProduct
(Delegator delegator, String idToFind, String goodIdentificationTypeId) static String
findProductId
(Delegator delegator, String idToFind) static String
findProductId
(Delegator delegator, String idToFind, String goodIdentificationTypeId) static List<GenericValue>
findProducts
(Delegator delegator, String idToFind) static List<GenericValue>
findProducts
(Delegator delegator, String idToFind, String goodIdentificationTypeId) static List<GenericValue>
findProductsById
(Delegator delegator, String idToFind, String goodIdentificationTypeId) static List<GenericValue>
findProductsById
(Delegator delegator, String idToFind, String goodIdentificationTypeId, boolean searchProductFirst, boolean searchAllId) Generic service to find product by id.static List<GenericValue>
getAggregatedAssocs
(Delegator delegator, String aggregatedProductId) static String
getAggregatedInstanceId
(Delegator delegator, String aggregatedProductId, String configId) static BigDecimal
getAverageProductRating
(Delegator delegator, String productId) static BigDecimal
getAverageProductRating
(Delegator delegator, String productId, String productStoreId) static BigDecimal
getAverageProductRating
(GenericValue product, String productStoreId) static BigDecimal
getAverageProductRating
(GenericValue product, List<GenericValue> reviews, String productStoreId) static List<GenericValue>
getCurrentProductCategories
(Delegator delegator, String productId) static List<GenericValue>
getCurrentProductCategories
(GenericValue product) static String
getGwpAlternativeOptionName
(LocalDispatcher dispatcher, Delegator delegator, String alternativeOptionProductId, Locale locale) Get the name to show to the customer for GWP alternative options.static String
getInstanceAggregatedId
(Delegator delegator, String instanceProductId) static Map<String,
List<GenericValue>> getOptionalProductFeatures
(Delegator delegator, String productId) static String
getOriginalProductId
(Delegator delegator, String productId) static GenericValue
getParentProduct
(String productId, Delegator delegator) static List<GenericValue>
static List<GenericValue>
getProductFeaturesByApplTypeId
(Delegator delegator, String productId, String productFeatureApplTypeId) gets productFeatures given a productFeatureApplTypeIdstatic List<GenericValue>
getProductFeaturesByApplTypeId
(GenericValue product, String productFeatureApplTypeId) static String
getProductTypeId
(Delegator delegator, String productId) static String
getProductVirtualVariantMethod
(Delegator delegator, String productId) static BigDecimal
getProductWeight
(GenericValue product, String desiredUomId, Delegator delegator, LocalDispatcher dispatcher) getRefurbishedProductIdSet
(String productId, Delegator delegator) static Set<GenericValue>
getVariantDistinguishingFeatures
(GenericValue variantProduct) Gets ProductFeature GenericValue for all distinguishing features of a variant product.static String
getVariantFromFeatureTree
(String productId, List<String> selectedFeatures, Delegator delegator) static List<GenericValue>
getVariantSelectionFeatures
(GenericValue variantProduct) For a given variant product, returns the list of features that would qualify it for selection from the virtual productstatic List<GenericValue>
getVariantVirtualAssocs
(GenericValue variantProduct) static String
getVariantVirtualId
(GenericValue variantProduct) static boolean
isAggregateService
(Delegator delegator, String aggregatedProductId) static boolean
isAlternativePacking
(Delegator delegator, String productId, String virtualVariantId) static boolean
isAmountRequired
(Delegator delegator, String productI) static boolean
isBillableToAddress
(GenericValue product, GenericValue postalAddress) static Boolean
isDecimalQuantityOrderAllowed
(Delegator delegator, String productId, String productStoreId) worker to test if product can be order with a decimal quantitystatic boolean
isDigital
(GenericValue product) static boolean
isPhysical
(GenericValue product) static boolean
isProductInventoryAvailableByFacility
(ProductConfigWrapper productConfig, String inventoryFacilityId, BigDecimal quantity, LocalDispatcher dispatcher) Invokes the getInventoryAvailableByFacility service, returns true if specified quantity is available for all the selected parts, else false.static boolean
isSellable
(Delegator delegator, String productId) static boolean
isSellable
(Delegator delegator, String productId, Timestamp atTime) static boolean
isSellable
(GenericValue product) static boolean
isSellable
(GenericValue product, Timestamp atTime) static boolean
isSerialized
(Delegator delegator, String productId) static boolean
isShippableToAddress
(GenericValue product, GenericValue postalAddress) static boolean
static boolean
shippingApplies
(GenericValue product) static boolean
taxApplies
(GenericValue product)
-
Method Details
-
shippingApplies
-
isBillableToAddress
-
isShippableToAddress
-
isSerialized
-
taxApplies
-
getInstanceAggregatedId
public static String getInstanceAggregatedId(Delegator delegator, String instanceProductId) throws GenericEntityException - Throws:
GenericEntityException
-
getAggregatedInstanceId
public static String getAggregatedInstanceId(Delegator delegator, String aggregatedProductId, String configId) throws GenericEntityException - Throws:
GenericEntityException
-
getAggregatedAssocs
public static List<GenericValue> getAggregatedAssocs(Delegator delegator, String aggregatedProductId) throws GenericEntityException - Throws:
GenericEntityException
-
getVariantVirtualId
- Throws:
GenericEntityException
-
getVariantVirtualAssocs
public static List<GenericValue> getVariantVirtualAssocs(GenericValue variantProduct) throws GenericEntityException - Throws:
GenericEntityException
-
isProductInventoryAvailableByFacility
public static boolean isProductInventoryAvailableByFacility(ProductConfigWrapper productConfig, String inventoryFacilityId, BigDecimal quantity, LocalDispatcher dispatcher) 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. -
getVariantDistinguishingFeatures
public static Set<GenericValue> getVariantDistinguishingFeatures(GenericValue variantProduct) throws GenericEntityException Gets ProductFeature GenericValue for all distinguishing features of a variant product. Distinguishing means all features that are selectable on the corresponding virtual product and standard on the variant plus all DISTINGUISHING_FEAT assoc type features on the variant.- Throws:
GenericEntityException
-
getGwpAlternativeOptionName
public static String getGwpAlternativeOptionName(LocalDispatcher dispatcher, Delegator delegator, String alternativeOptionProductId, Locale locale) Get the name to show to the customer for GWP alternative options. If the alternative is a variant, find the distinguishing features and show those instead of the name; if it is not a variant then show the PRODUCT_NAME content. -
getProductFeaturesByApplTypeId
public static List<GenericValue> getProductFeaturesByApplTypeId(Delegator delegator, String productId, String productFeatureApplTypeId) gets productFeatures given a productFeatureApplTypeId- Parameters:
delegator
-productId
-productFeatureApplTypeId
- - if null, returns ALL productFeatures, regardless of applType- Returns:
- List
-
getProductFeaturesByApplTypeId
public static List<GenericValue> getProductFeaturesByApplTypeId(GenericValue product, String productFeatureApplTypeId) -
getProductFeaturesApplIncludeMarketingPackage
public static List<GenericValue> getProductFeaturesApplIncludeMarketingPackage(GenericValue product) -
getProductVirtualVariantMethod
-
getSelectableProductFeaturesByTypesAndSeq
public static List<List<Map<String,String>>> getSelectableProductFeaturesByTypesAndSeq(GenericValue product) - Parameters:
product
-- Returns:
- list featureType and related featuresIds, description and feature price for this product ordered by type and sequence
-
getVariantSelectionFeatures
For a given variant product, returns the list of features that would qualify it for selection from the virtual product- Parameters:
variantProduct
- - the variant from which to derive the selection features- Returns:
- a List of ProductFeature GenericValues
-
getOptionalProductFeatures
-
calcOrderAdjustments
public static BigDecimal calcOrderAdjustments(List<GenericValue> orderHeaderAdjustments, BigDecimal subTotal, boolean includeOther, boolean includeTax, boolean includeShipping) -
calcOrderAdjustment
public static BigDecimal calcOrderAdjustment(GenericValue orderAdjustment, BigDecimal orderSubTotal) -
filterOrderAdjustments
public static List<GenericValue> filterOrderAdjustments(List<GenericValue> adjustments, boolean includeOther, boolean includeTax, boolean includeShipping, boolean forTax, boolean forShipping) -
getAverageProductRating
-
getAverageProductRating
public static BigDecimal getAverageProductRating(Delegator delegator, String productId, String productStoreId) -
getAverageProductRating
-
getAverageProductRating
public static BigDecimal getAverageProductRating(GenericValue product, List<GenericValue> reviews, String productStoreId) -
getCurrentProductCategories
-
getCurrentProductCategories
-
getParentProduct
-
isDigital
-
isPhysical
-
isVirtual
-
isAmountRequired
-
getProductTypeId
-
getProductWeight
public static BigDecimal getProductWeight(GenericValue product, String desiredUomId, Delegator delegator, LocalDispatcher dispatcher) -
findProductsById
public static List<GenericValue> findProductsById(Delegator delegator, String idToFind, String goodIdentificationTypeId, boolean searchProductFirst, boolean searchAllId) throws GenericEntityException Generic service to find product by id. By default return the product find by productId but you can pass searchProductFirst at false if you want search in goodIdentification before or pass searchAllId at true to find all product with this id (product.productId and goodIdentification.idValue)- Parameters:
delegator
- the delegatoridToFind
- the product id to findgoodIdentificationTypeId
- the good identification type id to usesearchProductFirst
- search first by product idsearchAllId
- search all product ids- Returns:
- return the list of products founds
- Throws:
GenericEntityException
-
findProductsById
public static List<GenericValue> findProductsById(Delegator delegator, String idToFind, String goodIdentificationTypeId) throws GenericEntityException - Throws:
GenericEntityException
-
findProductId
public static String findProductId(Delegator delegator, String idToFind, String goodIdentificationTypeId) throws GenericEntityException - Throws:
GenericEntityException
-
findProductId
public static String findProductId(Delegator delegator, String idToFind) throws GenericEntityException - Throws:
GenericEntityException
-
findProduct
public static GenericValue findProduct(Delegator delegator, String idToFind, String goodIdentificationTypeId) throws GenericEntityException - Throws:
GenericEntityException
-
findProducts
public static List<GenericValue> findProducts(Delegator delegator, String idToFind, String goodIdentificationTypeId) throws GenericEntityException - Throws:
GenericEntityException
-
findProducts
public static List<GenericValue> findProducts(Delegator delegator, String idToFind) throws GenericEntityException - Throws:
GenericEntityException
-
findProduct
public static GenericValue findProduct(Delegator delegator, String idToFind) throws GenericEntityException - Throws:
GenericEntityException
-
isSellable
public static boolean isSellable(Delegator delegator, String productId, Timestamp atTime) throws GenericEntityException - Throws:
GenericEntityException
-
isSellable
public static boolean isSellable(Delegator delegator, String productId) throws GenericEntityException - Throws:
GenericEntityException
-
isSellable
-
isSellable
-
getRefurbishedProductIdSet
public static Set<String> getRefurbishedProductIdSet(String productId, Delegator delegator) throws GenericEntityException - Throws:
GenericEntityException
-
getVariantFromFeatureTree
-
isAlternativePacking
-
getOriginalProductId
-
isDecimalQuantityOrderAllowed
public static Boolean isDecimalQuantityOrderAllowed(Delegator delegator, String productId, String productStoreId) throws GenericEntityException worker to test if product can be order with a decimal quantity- Parameters:
delegator
- : access to DBproductId
- : ref. of productproductStoreId
- : ref. of store- Returns:
- true if it can be ordered by decimal quantity
- Throws:
GenericEntityException
- to catch
-
isAggregateService
-
filterOutOfStockProducts
public static List<GenericValue> filterOutOfStockProducts(List<GenericValue> productsToFilter, LocalDispatcher dispatcher, Delegator delegator) throws GeneralException - Throws:
GeneralException
-