Class ProductWorker


  • public final class ProductWorker
    extends java.lang.Object
    Product Worker class to reduce code in JSPs.
    • Field Detail

      • module

        public static final java.lang.String module
    • 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)
      • 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 delegator
        idToFind - the product id to find
        goodIdentificationTypeId - the good identification type id to use
        searchProductFirst - search first by product id
        searchAllId - search all product ids
        Returns:
        return the list of products founds
        Throws:
        GenericEntityException
      • isSellable

        public static boolean isSellable​(GenericValue product)
      • isSellable

        public static boolean isSellable​(GenericValue product,
                                         java.sql.Timestamp atTime)
      • 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 DB
        productId - : 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)