Interface Product

All Superinterfaces:
Indexable, org.broadleafcommerce.common.copy.MultiTenantCloneable<Product>, Serializable
All Known Subinterfaces:
ProductBundle
All Known Implementing Classes:
ProductBundleImpl, ProductImpl

public interface Product extends Serializable, org.broadleafcommerce.common.copy.MultiTenantCloneable<Product>, Indexable
Implementations of this interface are used to hold data for a Product. A product is a general description of an item that can be sold (for example: a hat). Products are not sold or added to a cart. Skus which are specific items (for example: a XL Blue Hat) are sold or added to a cart.

You should implement this class if you want to make significant changes to how the Product is persisted. If you just want to add additional fields then you should extend ProductImpl.
Author:
btaylor
  • Method Details

    • getId

      Long getId()
      The id of the Product.
      Specified by:
      getId in interface Indexable
      Returns:
      the id of the Product
    • setId

      void setId(Long id)
      Sets the id of the Product.
      Parameters:
      id - - the id of the product
    • getName

      String getName()
      Returns the name of the product that is used for display purposes.

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Returns:
      the name of the product
    • setName

      void setName(String name)
      Sets the name of the product that is used for display purposes.

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Parameters:
      name - - the name of the Product
    • getDescription

      String getDescription()
      Returns a brief description of the product that is used for display.

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Returns:
      a brief description of the product
    • setDescription

      void setDescription(String description)
      Sets a brief description of the product that is used for display.

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Parameters:
      description - - a brief description of the product
    • getLongDescription

      String getLongDescription()
      Returns a long description of the product that is used for display.

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Returns:
      a long description of the product
    • setLongDescription

      void setLongDescription(String longDescription)
      Sets a long description of the product that is used for display.

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Parameters:
      longDescription - the long description
    • getActiveStartDate

      Date getActiveStartDate()
      Returns the first date a product will be available that is used to determine whether to display the product.

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Returns:
      the first date the product will be available
    • setActiveStartDate

      void setActiveStartDate(Date activeStartDate)
      Sets the first date a product will be available that is used to determine whether to display the product.

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Parameters:
      activeStartDate - - the first day the product is available
    • getActiveEndDate

      Date getActiveEndDate()
      Returns the last date a product will be available that is used to determine whether to display the product.

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Returns:
      the last day the product is available
    • setActiveEndDate

      void setActiveEndDate(Date activeEndDate)
      Sets the last date a product will be available that is used to determine whether to display the product.

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Parameters:
      activeEndDate - - the last day the product is available
    • isActive

      boolean isActive()
      Returns a boolean that indicates if the product is currently active.

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Returns:
      a boolean indicates if the product is active.
    • getDefaultSku

      Sku getDefaultSku()
      Gets the default Sku associated with this Product. A Product is required to have a default Sku which holds specific information about the Product like weight, dimensions, price, etc. Many of the Product attributes that have getters and setters on Product are actually pass-through to the default Sku.

      Products can also have multiple Skus associated with it that are represented by ProductOptions. For instance, a large, blue shirt. For more information on that relationship see getAdditionalSkus().
      Returns:
      the default Sku for this Product
    • setDefaultSku

      void setDefaultSku(Sku defaultSku)
      Sets the default Sku for this Product

      Note: this operation is cascaded with CascadeType.ALL which saves from having to persist the Product in 2 operations: first persist the Sku and then take the merged Sku, set it as this Product's default Sku, and then persist this Product.
      Parameters:
      defaultSku - - the Sku that should be the default for this Product
    • getMetaTitle

      String getMetaTitle()
      Gets the meta data title of the product
      Returns:
    • setMetaTitle

      void setMetaTitle(String metaTitle)
      Sets the meta data title of the product
      Parameters:
      metaTitle -
    • getMetaDescription

      String getMetaDescription()
      Gets the meta data description of the product
      Returns:
    • setMetaDescription

      void setMetaDescription(String metaDescription)
      Sets the meta data description of the product
      Parameters:
      metaDescription -
    • getCanonicalUrl

      String getCanonicalUrl()
      Gets the canonical URL of the product
      Returns:
    • setCanonicalUrl

      void setCanonicalUrl(String canonicalUrl)
      Sets the canonical URL of the product
      Parameters:
      canonicalUrl -
    • getExternalId

      String getExternalId()
    • getCanSellWithoutOptions

      Boolean getCanSellWithoutOptions()
      Returns:
      whether or not the default sku can be used for a multi-sku product in the case that no product options are set. Defaults to false if not specified. Note that this only affects multi-sku products.
    • setCanSellWithoutOptions

      void setCanSellWithoutOptions(Boolean canSellWithoutOptions)
      Sets whether or not the default sku can be sold in the case that no product options are specified. Note that this only affects multi-sku products.
      Parameters:
      canSellWithoutOptions -
    • getSkus

      @Deprecated List<Sku> getSkus()
      Deprecated.
      use #getAdditionalSkusXrefs() instead
      Returns a list of Skus filtered by whether the Skus are active or not. This list does not contain the getDefaultSku() and filters by Sku.isActive().
      Returns:
      a list of active Skus from getAdditionalSkus() for this Product
    • getAdditionalSkus

      List<Sku> getAdditionalSkus()
      Gets all the additional Skus associated with this Product. For instance, if this Product represented a T-shirt and you could pick the size of the T-shirt as a ProductOption (like "small", "medium", "large") this would return 3 Skus if you had different inventory or price constraints on each ProductOptionValue.

      This list does not take into account whether any of these additional Skus are active or not, nor does it contain the getDefaultSku() for this Product. For this functionality, see getSkus() and getAllSkus(), respectively.
      Returns:
      the additional Skus for this Product
    • setAdditionalSkus

      void setAdditionalSkus(List<Sku> skus)
      Sets the additional Skus associated to this Product. These additional Skus should come from ProductOptionValues and are used in instance where you need to track inventory or change pricing on a per-option value basis.
      Parameters:
      skus - - a List of Skus to associate with this Product, usually based off of ProductOptions
    • getAllSkus

      List<Sku> getAllSkus()
      Returns all the Skus that are associated with this Product (including getDefaultSku()) regardless of whether or not the Skus are active or not

      Note: in the event that the default Sku was added to the list of getAdditionalSkus(), it is filtered out so that only a single instance of getDefaultSku() is contained in the resulting list
      Returns:
      all the Skus associated to this Product
    • getAllSellableSkus

      List<Sku> getAllSellableSkus()
      Returns all skus that are sellable. If the product `canSellWithoutOptions` is true, the `defaultSku` is included in the list. Otherwise, the `defaultSku` is ignored.
      Returns:
      all the sellable Skus associated to this Product
    • getMedia

      Map<String,org.broadleafcommerce.common.media.domain.Media> getMedia()
      Gets the media for this product. This serves as a pass-through to the getDefaultSku() media
      Returns:
      the Media for the default Sku associated with this Product
      See Also:
    • setMedia

      void setMedia(Map<String,org.broadleafcommerce.common.media.domain.Media> media)
      Gets the media for this product. This serves as a pass-through to the getDefaultSku() media
      Parameters:
      media - Media map to set on the default Sku associated with this Product
      See Also:
    • getAllSkuMedia

      Map<String,org.broadleafcommerce.common.media.domain.Media> getAllSkuMedia()
      Convenience method for returning all of the media associated with this Product by adding all the media in getDefaultSku() as well as all the media in the Skus represented by getAdditionalSkus()
      Returns:
      all of the Media for all of the Skus for this Product
    • getCategory

      Category getCategory()
      Return the Category that contains this product
      Returns:
    • setCategory

      void setCategory(Category category)
      Set the Category that contains this product
      Parameters:
      category -
    • getDefaultCategory

      @Deprecated Category getDefaultCategory()
      Deprecated.
      use getCategory() instead
      Returns the default Category this product is associated with. This method will delegate to getCategory() by default, unless the "use.legacy.default.category.mode" property is set to true in the implementation's property file. If set to true, this method will use legacy behavior, which is to return the deprecated defaultCategory field.
    • setDefaultCategory

      @Deprecated void setDefaultCategory(Category defaultCategory)
      Deprecated.
      Sets the default Category to associate this product with. This method will delegate to setCategory(Category) by default, unless the "use.legacy.default.category.mode" property is set to true in the implementation's property file. If set to true, this method will use legacy behavior, which is to set the deprecated defaultCategory field.
      Parameters:
      defaultCategory - - the default Category to associate this product with
    • getModel

      String getModel()
      Returns the model number of the product
      Returns:
      the model number
    • setModel

      void setModel(String model)
      Sets the model number of the product
      Parameters:
      model -
    • getManufacturer

      String getManufacturer()
      Returns the manufacture name for this product
      Returns:
      the manufacture name
    • setManufacturer

      void setManufacturer(String manufacturer)
      Sets the manufacture for this product
      Parameters:
      manufacturer -
    • getDimension

      Dimension getDimension()
      Returns the Dimension for this product

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Returns:
      a ProductDimensions object
    • setDimension

      void setDimension(Dimension dimension)
      Sets the Dimension for this product

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Parameters:
      dimension -
    • getWidth

      BigDecimal getWidth()
      Returns the dimension width

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Returns:
      width dimension of the product
    • setWidth

      void setWidth(BigDecimal width)
      Sets the dimension width

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Parameters:
      width -
    • getHeight

      BigDecimal getHeight()
      Returns the dimension height

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Returns:
      height dimension of the product
    • setHeight

      void setHeight(BigDecimal height)
      Sets the dimension height

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Parameters:
      height -
    • getDepth

      BigDecimal getDepth()
      Returns the dimension depth

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Returns:
      width depth of the product
    • setDepth

      void setDepth(BigDecimal depth)
      Sets the dimension depth

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Parameters:
      depth -
    • getGirth

      BigDecimal getGirth()
      Gets the dimension girth

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Returns:
      the dimension girth
    • setGirth

      void setGirth(BigDecimal girth)
      Sets the dimension girth

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Parameters:
      girth -
    • getSize

      org.broadleafcommerce.common.vendor.service.type.ContainerSizeType getSize()
      Returns the dimension container size



      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()

      Returns:
      dimension container size
    • setSize

      void setSize(org.broadleafcommerce.common.vendor.service.type.ContainerSizeType size)
      Sets the dimension container size

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Parameters:
      size -
    • getContainer

      org.broadleafcommerce.common.vendor.service.type.ContainerShapeType getContainer()
      Gets the dimension container shape

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Returns:
      dimension container shape
    • setContainer

      void setContainer(org.broadleafcommerce.common.vendor.service.type.ContainerShapeType container)
      Sets the dimension container shape

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Parameters:
      container -
    • getDimensionString

      String getDimensionString()
      Returns a String representation of the dimension

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Returns:
      a dimension String
    • getWeight

      Weight getWeight()
      Returns the weight of the product

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Returns:
      weight of product
    • setWeight

      void setWeight(Weight weight)
      Sets the product weight

      Note: this is a convenience method that merely serves as a pass-through to the same method via getDefaultSku()
      Parameters:
      weight -
    • getCrossSaleProducts

      List<RelatedProduct> getCrossSaleProducts()
      Returns a List of this product's related Cross Sales
      Returns:
    • setCrossSaleProducts

      void setCrossSaleProducts(List<RelatedProduct> crossSaleProducts)
      Sets the related Cross Sales
      Parameters:
      crossSaleProducts -
    • getUpSaleProducts

      List<RelatedProduct> getUpSaleProducts()
      Returns a List of this product's related Up Sales
      Returns:
    • setUpSaleProducts

      void setUpSaleProducts(List<RelatedProduct> upSaleProducts)
      Sets the related Up Sales
      Parameters:
      upSaleProducts -
    • getProductAttributes

      Map<String,ProductAttribute> getProductAttributes()
      Generic key-value pair of attributes to associate to this Product for maximum extensibility.
      Returns:
      the attributes for this Product
    • setProductAttributes

      void setProductAttributes(Map<String,ProductAttribute> productAttributes)
      Sets a generic list of key-value pairs for Product
      Parameters:
      productAttributes -
    • getMultiValueProductAttributes

      Map<String,ProductAttribute> getMultiValueProductAttributes()
    • getPromoMessage

      String getPromoMessage()
      Gets the promotional message for this Product. For instance, this could be a limited-time Product
      Returns:
      the Product's promotional message
    • setPromoMessage

      void setPromoMessage(String promoMessage)
      Sets the promotional message for this Product
      Parameters:
      promoMessage -
    • getProductOptions

      @Deprecated List<ProductOption> getProductOptions()
      Deprecated.
      use getProductOptionXrefs instead
      The available ProductOptions for this Product. For instance, if this Product is a T-Shirt, you might be able to specify a size and color. This would be modeled by 2 ProductOptions, each that could have multiple ProductOptionValues (which could be "small" "medium" "large", "blue", "yellow", "green"). For specific pricing or inventory needs on a per-value basis, multiple Skus can be associated to this Product based off of the ProductOptionValues
      Returns:
      the ProductOptions for this Product
    • setProductOptions

      @Deprecated void setProductOptions(List<ProductOption> productOptions)
      Deprecated.
      use setProductOptionXrefs instead
      Sets the list of available ProductOptions for this Product
      Parameters:
      productOptions -
    • getProductOptionXrefs

      List<ProductOptionXref> getProductOptionXrefs()
    • setProductOptionXrefs

      void setProductOptionXrefs(List<ProductOptionXref> productOptions)
    • getProductOptionValuesMap

      Map<String,Set<String>> getProductOptionValuesMap()
      Returns a Map of product option values, keyed by the product option name. E.g. "color":["red","green","black"]
      Returns:
    • getUrl

      String getUrl()
      A product can have a designated URL. When set, the ProductHandlerMapping will check for this URL and forward this user to the getDisplayTemplate().

      Alternatively, most sites will rely on the getGeneratedUrl() to define the url for a product page.

      Returns:
      See Also:
      • org.broadleafcommerce.core.web.catalog.ProductHandlerMapping
    • setUrl

      void setUrl(String url)
      Sets the URL that a customer could type in to reach this product.
      Parameters:
      url -
    • getOverrideGeneratedUrl

      Boolean getOverrideGeneratedUrl()
      Returns:
      the flag for whether or not the URL should not be generated in the admin
    • setOverrideGeneratedUrl

      void setOverrideGeneratedUrl(Boolean overrideGeneratedUrl)
      Sets the flag for whether or not the URL should not be generated in the admin
      Parameters:
      overrideGeneratedUrl -
    • getUrlKey

      String getUrlKey()
      Sets a url-fragment. By default, the system will attempt to create a unique url-fragment for this product by taking the {@link Product.getName()} and removing special characters and replacing dashes with spaces.
    • setUrlKey

      void setUrlKey(String url)
      Sets a url-fragment to be used with this product. By default, the system will attempt to create a unique url-fragment for this product by taking the {@link Product.getName()} and removing special characters and replacing dashes with spaces.
    • getDisplayTemplate

      String getDisplayTemplate()
      Returns the name of a display template that is used to render this product. Most implementations have a default template for all products. This allows for the user to define a specific template to be used by this product.
      Returns:
    • setDisplayTemplate

      void setDisplayTemplate(String displayTemplate)
      Sets the name of a display template that is used to render this product. Most implementations have a default template for all products. This allows for the user to define a specific template to be used by this product.
      Parameters:
      displayTemplate -
    • getGeneratedUrl

      String getGeneratedUrl()
      Generates a URL that can be used to access the product. Builds the url by combining the url of the default category with the getUrlKey() of this product.
    • getCumulativeCrossSaleProducts

      List<RelatedProduct> getCumulativeCrossSaleProducts()
      Returns a list of the cross sale products for this product as well all cross sale products in all parent categories of this product.
      Returns:
      the cumulative cross sale products
    • getCumulativeUpSaleProducts

      List<RelatedProduct> getCumulativeUpSaleProducts()
      Returns a list of the upsale products for this product as well as all upsale products in all parent categories of this product.
      Returns:
      the cumulative upsale products
    • clearDynamicPrices

      void clearDynamicPrices()
      Removes any currently stored dynamic pricing
    • getAllParentCategoryXrefs

      List<CategoryProductXref> getAllParentCategoryXrefs()
      Retrieve all the xref entities linking this product to parent categories
    • setAllParentCategoryXrefs

      void setAllParentCategoryXrefs(List<CategoryProductXref> allParentCategories)
      Set all the xref entities linking this product to parent categories
    • getAllParentCategoryIds

      List<String> getAllParentCategoryIds()
      Returns all parent Category ids this product is associated with.
      Returns:
      the all parent category ids for this product
    • getAllParentCategories

      @Deprecated List<Category> getAllParentCategories()
      Deprecated.
      Use getAllParentCategoryXrefs() instead.
      Returns all parent Category(s) this product is associated with.
      Returns:
      the all parent categories for this product
    • setAllParentCategories

      @Deprecated void setAllParentCategories(List<Category> allParentCategories)
      Deprecated.
      Use setAllParentCategoryXrefs() instead.
      Sets all parent Categorys this product is associated with.
      Parameters:
      allParentCategories - - a List of all parent Category(s) to associate this product with
    • getTaxCode

      String getTaxCode()
      Returns the tax code of the product. If the tax code is null, then returns the tax code of this products category.
      Returns:
      taxCode
    • setTaxCode

      void setTaxCode(String taxCode)
      Sets the tax code for this product.
      Parameters:
      taxCode -
    • hasRetailPrice

      boolean hasRetailPrice()
      In most implementations, including the default Broadleaf demo store, if a product doesn't have a retail price, it can't be sold. This method returns true if in the current context, the product has a price. The current context may be different when accessed in an entperise context like one using PriceLists or MultiTentant.
      Returns:
    • getRetailPrice

      org.broadleafcommerce.common.money.Money getRetailPrice()
      Convenience method, references to defaultSku.retailPrice
      Returns:
    • getSalePrice

      org.broadleafcommerce.common.money.Money getSalePrice()
      Convenience method, references defaultSku.salePrice
      Returns:
    • getPrice

      org.broadleafcommerce.common.money.Money getPrice()
      Convenience method, references defaultSku.price
      Returns:
    • isOnSale

      boolean isOnSale()
      Convenience method, references defaultSku.onSale
      Returns:
    • getMargin

      org.broadleafcommerce.common.money.Money getMargin()
      added just for convenience, references defaultSku.margin
      Returns:
    • getParentCategoryHierarchyIds

      List<Long> getParentCategoryHierarchyIds()
      The specified PromotionMessages for this Product that will override the Offer's default PromotionMessage.
      Returns:
      the Category Ids for this Product's parent Category hierarchy
    • getEnableDefaultSkuInInventory

      Boolean getEnableDefaultSkuInInventory()
    • setEnableDefaultSkuInInventory

      void setEnableDefaultSkuInInventory(Boolean enableUseDefaultSkuInventory)
      enables or disables that inventory will be tracked by default sku instead of alt sku in case of alt sku existence
      Parameters:
      enableUseDefaultSkuInventory -