Package org.apache.ofbiz.product.product
Class ProductWorker
- java.lang.Object
-
- org.apache.ofbiz.product.product.ProductWorker
-
public final class ProductWorker extends java.lang.Object
Product Worker class to reduce code in JSPs.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
module
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.math.BigDecimal
calcOrderAdjustment(GenericValue orderAdjustment, java.math.BigDecimal orderSubTotal)
static java.math.BigDecimal
calcOrderAdjustments(java.util.List<GenericValue> orderHeaderAdjustments, java.math.BigDecimal subTotal, boolean includeOther, boolean includeTax, boolean includeShipping)
static java.util.List<GenericValue>
filterOrderAdjustments(java.util.List<GenericValue> adjustments, boolean includeOther, boolean includeTax, boolean includeShipping, boolean forTax, boolean forShipping)
static java.util.List<GenericValue>
filterOutOfStockProducts(java.util.List<GenericValue> productsToFilter, LocalDispatcher dispatcher, Delegator delegator)
static GenericValue
findProduct(Delegator delegator, java.lang.String idToFind)
static GenericValue
findProduct(Delegator delegator, java.lang.String idToFind, java.lang.String goodIdentificationTypeId)
static java.lang.String
findProductId(Delegator delegator, java.lang.String idToFind)
static java.lang.String
findProductId(Delegator delegator, java.lang.String idToFind, java.lang.String goodIdentificationTypeId)
static java.util.List<GenericValue>
findProducts(Delegator delegator, java.lang.String idToFind)
static java.util.List<GenericValue>
findProducts(Delegator delegator, java.lang.String idToFind, java.lang.String goodIdentificationTypeId)
static java.util.List<GenericValue>
findProductsById(Delegator delegator, java.lang.String idToFind, java.lang.String goodIdentificationTypeId)
static java.util.List<GenericValue>
findProductsById(Delegator delegator, java.lang.String idToFind, java.lang.String goodIdentificationTypeId, boolean searchProductFirst, boolean searchAllId)
Generic service to find product by id.static java.util.List<GenericValue>
getAggregatedAssocs(Delegator delegator, java.lang.String aggregatedProductId)
static java.lang.String
getAggregatedInstanceId(Delegator delegator, java.lang.String aggregatedProductId, java.lang.String configId)
static java.math.BigDecimal
getAverageProductRating(Delegator delegator, java.lang.String productId)
static java.math.BigDecimal
getAverageProductRating(Delegator delegator, java.lang.String productId, java.lang.String productStoreId)
static java.math.BigDecimal
getAverageProductRating(GenericValue product, java.lang.String productStoreId)
static java.math.BigDecimal
getAverageProductRating(GenericValue product, java.util.List<GenericValue> reviews, java.lang.String productStoreId)
static java.util.List<GenericValue>
getCurrentProductCategories(Delegator delegator, java.lang.String productId)
static java.util.List<GenericValue>
getCurrentProductCategories(GenericValue product)
static java.lang.String
getGwpAlternativeOptionName(LocalDispatcher dispatcher, Delegator delegator, java.lang.String alternativeOptionProductId, java.util.Locale locale)
Get the name to show to the customer for GWP alternative options.static java.lang.String
getInstanceAggregatedId(Delegator delegator, java.lang.String instanceProductId)
static java.util.Map<java.lang.String,java.util.List<GenericValue>>
getOptionalProductFeatures(Delegator delegator, java.lang.String productId)
static java.lang.String
getOriginalProductId(Delegator delegator, java.lang.String productId)
static GenericValue
getParentProduct(java.lang.String productId, Delegator delegator)
static java.util.List<GenericValue>
getProductFeaturesByApplTypeId(Delegator delegator, java.lang.String productId, java.lang.String productFeatureApplTypeId)
gets productFeatures given a productFeatureApplTypeIdstatic java.util.List<GenericValue>
getProductFeaturesByApplTypeId(GenericValue product, java.lang.String productFeatureApplTypeId)
static java.lang.String
getProductTypeId(Delegator delegator, java.lang.String productId)
static java.lang.String
getProductVirtualVariantMethod(Delegator delegator, java.lang.String productId)
static java.math.BigDecimal
getProductWeight(GenericValue product, java.lang.String desiredUomId, Delegator delegator, LocalDispatcher dispatcher)
static java.util.Set<java.lang.String>
getRefurbishedProductIdSet(java.lang.String productId, Delegator delegator)
static java.util.List<java.util.List<java.util.Map<java.lang.String,java.lang.String>>>
getSelectableProductFeaturesByTypesAndSeq(GenericValue product)
static java.util.Set<GenericValue>
getVariantDistinguishingFeatures(GenericValue variantProduct)
Gets ProductFeature GenericValue for all distinguishing features of a variant product.static java.lang.String
getVariantFromFeatureTree(java.lang.String productId, java.util.List<java.lang.String> selectedFeatures, Delegator delegator)
static java.util.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 java.util.List<GenericValue>
getVariantVirtualAssocs(GenericValue variantProduct)
static java.lang.String
getVariantVirtualId(GenericValue variantProduct)
static boolean
isAggregateService(Delegator delegator, java.lang.String aggregatedProductId)
static boolean
isAlternativePacking(Delegator delegator, java.lang.String productId, java.lang.String virtualVariantId)
static boolean
isAmountRequired(Delegator delegator, java.lang.String productI)
static boolean
isBillableToAddress(GenericValue product, GenericValue postalAddress)
static java.lang.Boolean
isDecimalQuantityOrderAllowed(Delegator delegator, java.lang.String productId, java.lang.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, java.lang.String inventoryFacilityId, java.math.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, java.lang.String productId)
static boolean
isSellable(Delegator delegator, java.lang.String productId, java.sql.Timestamp atTime)
static boolean
isSellable(GenericValue product)
static boolean
isSellable(GenericValue product, java.sql.Timestamp atTime)
static boolean
isSerialized(Delegator delegator, java.lang.String productId)
static boolean
isShippableToAddress(GenericValue product, GenericValue postalAddress)
static boolean
isVirtual(Delegator delegator, java.lang.String productI)
static boolean
shippingApplies(GenericValue product)
static boolean
taxApplies(GenericValue product)
-
-
-
Method Detail
-
shippingApplies
public static boolean shippingApplies(GenericValue product)
-
isBillableToAddress
public static boolean isBillableToAddress(GenericValue product, GenericValue postalAddress)
-
isShippableToAddress
public static boolean isShippableToAddress(GenericValue product, GenericValue postalAddress)
-
isSerialized
public static boolean isSerialized(Delegator delegator, java.lang.String productId)
-
taxApplies
public static boolean taxApplies(GenericValue product)
-
getInstanceAggregatedId
public static java.lang.String getInstanceAggregatedId(Delegator delegator, java.lang.String instanceProductId) throws GenericEntityException
- Throws:
GenericEntityException
-
getAggregatedInstanceId
public static java.lang.String getAggregatedInstanceId(Delegator delegator, java.lang.String aggregatedProductId, java.lang.String configId) throws GenericEntityException
- Throws:
GenericEntityException
-
getAggregatedAssocs
public static java.util.List<GenericValue> getAggregatedAssocs(Delegator delegator, java.lang.String aggregatedProductId) throws GenericEntityException
- Throws:
GenericEntityException
-
getVariantVirtualId
public static java.lang.String getVariantVirtualId(GenericValue variantProduct) throws GenericEntityException
- Throws:
GenericEntityException
-
getVariantVirtualAssocs
public static java.util.List<GenericValue> getVariantVirtualAssocs(GenericValue variantProduct) throws GenericEntityException
- Throws:
GenericEntityException
-
isProductInventoryAvailableByFacility
public static boolean isProductInventoryAvailableByFacility(ProductConfigWrapper productConfig, java.lang.String inventoryFacilityId, java.math.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 java.util.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 java.lang.String getGwpAlternativeOptionName(LocalDispatcher dispatcher, Delegator delegator, java.lang.String alternativeOptionProductId, java.util.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 java.util.List<GenericValue> getProductFeaturesByApplTypeId(Delegator delegator, java.lang.String productId, java.lang.String productFeatureApplTypeId)
gets productFeatures given a productFeatureApplTypeId- Parameters:
delegator
-productId
-productFeatureApplTypeId
- - if null, returns ALL productFeatures, regardless of applType- Returns:
- List
-
getProductFeaturesByApplTypeId
public static java.util.List<GenericValue> getProductFeaturesByApplTypeId(GenericValue product, java.lang.String productFeatureApplTypeId)
-
getProductVirtualVariantMethod
public static java.lang.String getProductVirtualVariantMethod(Delegator delegator, java.lang.String productId)
-
getSelectableProductFeaturesByTypesAndSeq
public static java.util.List<java.util.List<java.util.Map<java.lang.String,java.lang.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
public static java.util.List<GenericValue> getVariantSelectionFeatures(GenericValue variantProduct)
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
public static java.util.Map<java.lang.String,java.util.List<GenericValue>> getOptionalProductFeatures(Delegator delegator, java.lang.String productId)
-
calcOrderAdjustments
public static java.math.BigDecimal calcOrderAdjustments(java.util.List<GenericValue> orderHeaderAdjustments, java.math.BigDecimal subTotal, boolean includeOther, boolean includeTax, boolean includeShipping)
-
calcOrderAdjustment
public static java.math.BigDecimal calcOrderAdjustment(GenericValue orderAdjustment, java.math.BigDecimal orderSubTotal)
-
filterOrderAdjustments
public static java.util.List<GenericValue> filterOrderAdjustments(java.util.List<GenericValue> adjustments, boolean includeOther, boolean includeTax, boolean includeShipping, boolean forTax, boolean forShipping)
-
getAverageProductRating
public static java.math.BigDecimal getAverageProductRating(Delegator delegator, java.lang.String productId)
-
getAverageProductRating
public static java.math.BigDecimal getAverageProductRating(Delegator delegator, java.lang.String productId, java.lang.String productStoreId)
-
getAverageProductRating
public static java.math.BigDecimal getAverageProductRating(GenericValue product, java.lang.String productStoreId)
-
getAverageProductRating
public static java.math.BigDecimal getAverageProductRating(GenericValue product, java.util.List<GenericValue> reviews, java.lang.String productStoreId)
-
getCurrentProductCategories
public static java.util.List<GenericValue> getCurrentProductCategories(Delegator delegator, java.lang.String productId)
-
getCurrentProductCategories
public static java.util.List<GenericValue> getCurrentProductCategories(GenericValue product)
-
getParentProduct
public static GenericValue getParentProduct(java.lang.String productId, Delegator delegator)
-
isDigital
public static boolean isDigital(GenericValue product)
-
isPhysical
public static boolean isPhysical(GenericValue product)
-
isVirtual
public static boolean isVirtual(Delegator delegator, java.lang.String productI)
-
isAmountRequired
public static boolean isAmountRequired(Delegator delegator, java.lang.String productI)
-
getProductTypeId
public static java.lang.String getProductTypeId(Delegator delegator, java.lang.String productId)
-
getProductWeight
public static java.math.BigDecimal getProductWeight(GenericValue product, java.lang.String desiredUomId, Delegator delegator, LocalDispatcher dispatcher)
-
findProductsById
public static java.util.List<GenericValue> findProductsById(Delegator delegator, java.lang.String idToFind, java.lang.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 java.util.List<GenericValue> findProductsById(Delegator delegator, java.lang.String idToFind, java.lang.String goodIdentificationTypeId) throws GenericEntityException
- Throws:
GenericEntityException
-
findProductId
public static java.lang.String findProductId(Delegator delegator, java.lang.String idToFind, java.lang.String goodIdentificationTypeId) throws GenericEntityException
- Throws:
GenericEntityException
-
findProductId
public static java.lang.String findProductId(Delegator delegator, java.lang.String idToFind) throws GenericEntityException
- Throws:
GenericEntityException
-
findProduct
public static GenericValue findProduct(Delegator delegator, java.lang.String idToFind, java.lang.String goodIdentificationTypeId) throws GenericEntityException
- Throws:
GenericEntityException
-
findProducts
public static java.util.List<GenericValue> findProducts(Delegator delegator, java.lang.String idToFind, java.lang.String goodIdentificationTypeId) throws GenericEntityException
- Throws:
GenericEntityException
-
findProducts
public static java.util.List<GenericValue> findProducts(Delegator delegator, java.lang.String idToFind) throws GenericEntityException
- Throws:
GenericEntityException
-
findProduct
public static GenericValue findProduct(Delegator delegator, java.lang.String idToFind) throws GenericEntityException
- Throws:
GenericEntityException
-
isSellable
public static boolean isSellable(Delegator delegator, java.lang.String productId, java.sql.Timestamp atTime) throws GenericEntityException
- Throws:
GenericEntityException
-
isSellable
public static boolean isSellable(Delegator delegator, java.lang.String productId) throws GenericEntityException
- Throws:
GenericEntityException
-
isSellable
public static boolean isSellable(GenericValue product)
-
isSellable
public static boolean isSellable(GenericValue product, java.sql.Timestamp atTime)
-
getRefurbishedProductIdSet
public static java.util.Set<java.lang.String> getRefurbishedProductIdSet(java.lang.String productId, Delegator delegator) throws GenericEntityException
- Throws:
GenericEntityException
-
getVariantFromFeatureTree
public static java.lang.String getVariantFromFeatureTree(java.lang.String productId, java.util.List<java.lang.String> selectedFeatures, Delegator delegator)
-
isAlternativePacking
public static boolean isAlternativePacking(Delegator delegator, java.lang.String productId, java.lang.String virtualVariantId)
-
getOriginalProductId
public static java.lang.String getOriginalProductId(Delegator delegator, java.lang.String productId)
-
isDecimalQuantityOrderAllowed
public static java.lang.Boolean isDecimalQuantityOrderAllowed(Delegator delegator, java.lang.String productId, java.lang.String productStoreId) throws GenericEntityException
worker to test if product can be order with a decimal quantity- Parameters:
delegator
- : access to DBproductId
- : ref. of product * @param productStoreId : ref. of store- Returns:
- true if it can be ordered by decimal quantity
- Throws:
GenericEntityException
- to catch
-
isAggregateService
public static boolean isAggregateService(Delegator delegator, java.lang.String aggregatedProductId)
-
filterOutOfStockProducts
public static java.util.List<GenericValue> filterOutOfStockProducts(java.util.List<GenericValue> productsToFilter, LocalDispatcher dispatcher, Delegator delegator) throws GeneralException
- Throws:
GeneralException
-
-