java.lang.Object
com.broadleafcommerce.catalog.domain.product.Product
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ContextStateAware, com.broadleafcommerce.money.CurrencyConsumer, Serializable, javax.money.CurrencySupplier

public class Product extends Object implements Serializable, com.broadleafcommerce.data.tracking.core.ContextStateAware, com.broadleafcommerce.money.CurrencyConsumer, javax.money.CurrencySupplier
The main domain that the Broadleaf Catalog is based around. Products can have links to other products, to categories, etc
Author:
Phillip Verheyden (phillipuniverse)
See Also:
  • Constructor Details

  • Method Details

    • getAttribute

      public <T> T getAttribute(String name)
    • isActive

      public boolean isActive()
      Inactive products are by default NOT searchable, NOT browseable, and NOT purchaseable.
      Returns:
      the active state of this current product
      See Also:
    • isOnSale

      public boolean isOnSale()
      An item is on sale if both getDefaultPrice() and getSalePrice() are both set and getSalePrice() is less than the defaultPrice
      Returns:
      whether or not the item is on sale
    • getBusinessType

      public String getBusinessType()
    • getPriceWithDependentItems

      public javax.money.MonetaryAmount getPriceWithDependentItems()
      Calculates the total with the includedProducts and DefaultProductOptionType.ITEM_CHOICE type options that have ItemChoice.getMinimumQuantity() greater than 0.
      Returns:
      sum of IncludedProducts' and ItemChoices' prices.
    • getId

      public String getId()
      Returns:
      the context ID of the product
    • getName

      public String getName()
      Customer-facing name of this product. This can also be overridden at the Variant level
      Returns:
      the display name of this product
    • getUri

      public String getUri()
      SEO-friendly URI to identify this product. This is usually generated with some URL-safe version of the main category name along with a url-friendly version of name
      Returns:
      the URI used to refer to this Product
    • getDescription

      public String getDescription()
      Description of the product that can include HTML in implementations where a WYSIWYG editor manages this field.
      Returns:
      the description of this Product, can contain HTML
    • getSku

      public String getSku()
      This uniquely identifies this product in the catalog when it is sold and is used for other contexts like inventory and pricing.
      Returns:
      the Stock Keeping Unit identifier which means that this Product is sold in the store
    • getUpc

      public String getUpc()
      Universal product code that identifies this product. This is usually only relevant when this product is sold individually without any variants
      Returns:
      the the Universal Product Code associated with this Product
    • getExternalId

      public String getExternalId()
      This is an arbitrary ID, typically assigned by or used by 1st or 3rd party systems that are not Broadleaf.
      Returns:
      an external ID
    • getCurrency

      public javax.money.CurrencyUnit getCurrency()
      Currency for all of the prices on this product
      Specified by:
      getCurrency in interface javax.money.CurrencySupplier
      Returns:
      the currency to use for all of the prices on this product
    • getPricingKey

      public String getPricingKey()
      System-wide unique identifier to configure specific pricing for the product. Relevant if pricing data is managed in a separate system or data store, like the Broadleaf pricing services.
      Returns:
      a unique key to identify this product
    • getMsrp

      public javax.money.MonetaryAmount getMsrp()
      Suggested retail price for the product. This is generally only used for display and should not have any true pricing logic tied to it.
      Returns:
      the suggested retail price
      See Also:
      • currency
    • getDefaultPrice

      public javax.money.MonetaryAmount getDefaultPrice()

      The default price that should be used if there is not a salePrice set. This price can also be used as the default price for all of the Variants as well.

      For more advance pricing calculations, consider hiding this field in the API and removing support for it in lieu of managing prices outside of this service.

      Always included in the API even if set to null to indicate whether or not this was explicitly set

      Returns:
      the default price of the Product, non-null only in scenarios where this Product is intended to be sold in the store. Set to null if managing prices at the Variant level
    • getSalePrice

      public javax.money.MonetaryAmount getSalePrice()
      Indicates that this product is on sale. This should take priority over the default price if this salePrice is lower than the defaultPrice.
      Returns:
      the sale price, indicating that the product is on sale
    • getCost

      public javax.money.MonetaryAmount getCost()
      Can be used in display or as a part of more complex pricing algorithms.
      Returns:
      the cost of this product
    • getMetaTitle

      public String getMetaTitle()
      Used for SEO data in <title> tag in a product detail page. If this is unset, the name should be used.
      Returns:
      the meta title used for SEO data in product details page title
    • getMetaDescription

      public String getMetaDescription()
      Used for SEO data in <meta description=""> in a product detail page. If this is unset, the description should be used
      Returns:
      the meta description used for SEO data in product details page description
    • getDisplayTemplate

      public String getDisplayTemplate()
      Defines the display template. The display template can be used to help create a unique key that drives the presentation layer destination for this category. For example, if using Spring MVC with Thymeleaf, this could be a path to a Thymeleaf template. If using a frontend view technology like React, this could point to a specific React component.
      Returns:
      the display template to use for this product
    • isOnline

      public boolean isOnline()

      Whether or not this product should be visible at all in the store. A product that is offline is not searchable, visible, or purchasable. A product that is offline behaves as if it falls outside the active date range. It is not returned from storefront requests by default.

      Defaults to true

      Returns:
      whether or not this product is visible in the store
    • isDiscountable

      public boolean isDiscountable()

      Whether or not this product be applied to any offers or promotions.

      Defaults to true

      Returns:
      whether or not this product can be applied to any offers or promotions
    • getInventoryType

      public String getInventoryType()
      Describes the product's type of fulfillment - ie is it a physical or virtual item?

      Defaults to InventoryType.PHYSICAL

      Returns:
      the product's type of inventory
      See Also:
    • getMergingType

      public String getMergingType()
      Determines how this Product should merge with other similar items when it gets added to a cart. This will override the global setting on item merging. Out of box supported values are those in DefaultMergingType.
      Returns:
      the merging type to use for this Product
    • isAvailableOnline

      public boolean isAvailableOnline()
      Whether or not this product is available online - ie inventory is available somewhere to fulfill this product.

      Defaults to true

      Returns:
      Whether or not this product is available online.
    • getInventoryCheckStrategy

      public String getInventoryCheckStrategy()
      Describes when the product's inventory should be checked for availability.
      Returns:
      the product's inventory check strategy
      See Also:
    • getInventoryReservationStrategy

      public String getInventoryReservationStrategy()
      Describes when the product's inventory should be reserved.
      Returns:
      the product's inventory reservation strategy
      See Also:
    • isEligibleForPickup

      public boolean isEligibleForPickup()
      Whether or not this Product can be picked up at a store rather than just be shipped
      Returns:
      if this Product can be picked up at a store
    • getFulfillmentFlatRates

      public Map<String,FulfillmentFlatRate> getFulfillmentFlatRates()
      A map of flat rates for fulfilling (e.g., shipping) this product for a particular fulfillment option type (e.g., standard shipping). Depending on if the option is configured to use flat rates, this flat rate will be used in calculating the cost of fulfilling this product.

      The key of the map is the type of the fulfillment option such as FIXED_STANDARD or BANDED_PRICE_EXPRESS.

      Returns:
      Map of Fulfillment option types to flat rates for this product.
      See Also:
    • getActiveStartDate

      public Instant getActiveStartDate()
      Start of when this product should be active.
      Returns:
      the date when this product should start being active
    • getActiveEndDate

      public Instant getActiveEndDate()
      End when this product is not longer active. Unset indicates that it is always active.
      Returns:
      the date when this product should no longer be active
      See Also:
    • getDimension

      public Dimensions getDimension()
      Returns:
      the dimensions of this product
    • getWeight

      public Weight getWeight()
      Returns:
      the weight of this product
    • isSearchable

      public boolean isSearchable()

      Whether or not this product shows up in search. Usually this matches whether or not the product is individuallySold

      This defaults to true

      Returns:
      whether or not this product shows up in search
    • isIndividuallySold

      public boolean isIndividuallySold()

      If this product or any of its variants can be sold individually in the store, or if they must be apart of another product as an add-on. Usually if a product is not individually sold then it should also not show up in search.

      This defaults to true.

      Returns:
      whether or not this product or any of its variants can be sold individually
      See Also:
      • searchable
    • isMerchandisingProduct

      @Deprecated public boolean isMerchandisingProduct()
      Deprecated.
      please use productType instead.
      This product is not sold itself, but is a sort of container for subordinate items. This allows for configurable products with different user choices through ProductOption
      Returns:
      true if this product is a shell container or false otherwise
    • getProductType

      public String getProductType()
      Defines the type of the product. This affects how the product is displayed and managed in the admin UI, how it is handled by cart and order operations, and how it gets indexed by Search Services. The default types are defined by DefaultProductType.
      Returns:
      The type of the product
      See Also:
    • getKeywords

      public List<String> getKeywords()
      Generally additional search terms that should be used when customers search for this product.
      Returns:
      additional search terms that should be used when customers search for this product
    • getAttributes

      public Map<String,Attribute> getAttributes()
      Dynamic attributes that are a part of the product. This is an admin-centered concept
      Returns:
      dynamic attributes that are a part of the product
    • getIncludedProducts

      public List<IncludedProduct> getIncludedProducts()

      Additional products that are always included with the product, no matter what. Used to configure "bundles" or "kits".

      If some of these items should be optional or the user should decide which additional items are added to their cart, use options instead.

      Returns:
      additional products that bundle with this product as their parent
      See Also:
    • getOptions

      public List<ProductOption> getOptions()
      Drives additional information that the customer should enter when purchasing this product. This can be in the form of additional variations, additional items that can be bundled with this product or simply more information that the customer needs to enter about what they are purchasing (like a personalized message).
      Returns:
      different options that the user can configure to further refine their purchase.
    • getReviewsSummary

      public ReviewsSummary getReviewsSummary()
      The summary of reviews for this product.
      Returns:
      The summary of reviews for this product.
    • getPrimaryAsset

      public ProductAsset getPrimaryAsset()
      The ProductAsset associated with this product marked as ProductAsset.isPrimary(). By default, this is only hydrated for API callers.
      Returns:
      The primary ProductAsset for this product.
    • getPrimaryCategory

      @Nullable public Category getPrimaryCategory()
      The Category associated with this product where the CategoryProduct relationship is marked as CategoryProduct.isPrimary().

      This field is not persisted on the product - instead, this is a dynamically set/hydrated value for API callers to conveniently manage the primary CategoryProduct relationship as part of Product API create/replace calls.

      It is not necessarily respected or hydrated in all scenarios.

      Returns:
      the category that is associated with this product as the primary category
      See Also:
    • getTags

      public List<String> getTags()
      A list of simple labels used to categorize the product
      Returns:
      a list of simple labels used to categorize the product
    • getBrand

      @Nullable public DataDrivenEnum getBrand()
      Returns:
      the brand of this product
    • getMerchandisingType

      @Nullable public DataDrivenEnum getMerchandisingType()
      Returns:
      the merchandising type of this product
    • getTargetDemographic

      @Nullable public DataDrivenEnum getTargetDemographic()
      Returns:
      the target demographic of this product
    • getContextState

      public com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState getContextState()
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      getContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Returns:
      a subset of Tracking information to expose the context state for this object
    • getTaxCode

      public String getTaxCode()
      The tax code for this product.
      Returns:
      The tax code for this product.
    • getMinimumThreshold

      public Integer getMinimumThreshold()
      The minimum count of this product that must be added in a cart.
      Returns:
      the minimum count of this product that must be added in a cart
    • getMaximumThreshold

      public Integer getMaximumThreshold()
      The maximum count of this product that must be added in a cart.
      Returns:
      the maximum count of this product that must be added in a cart
    • getDefaultVariant

      public Variant getDefaultVariant()
      When the `productType` is `VARIANT_BASED` this represents the default.
    • setId

      public void setId(String id)
      Parameters:
      id - the context ID of the product
    • setName

      public void setName(String name)
      Customer-facing name of this product. This can also be overridden at the Variant level
      Parameters:
      name - the name of this product suitable for display
    • setUri

      public void setUri(String uri)
      SEO-friendly URI to identify this product. This is usually generated with some URL-safe version of the main category name along with a url-friendly version of name
      Parameters:
      uri - the uniquely identifiable URI of this Product
    • setDescription

      public void setDescription(String description)
      Description of the product that can include HTML in implementations where a WYSIWYG editor manages this field.
      Parameters:
      description - of this Product with HTML if necessary
    • setSku

      public void setSku(String sku)
      This uniquely identifies this product in the catalog when it is sold and is used for other contexts like inventory and pricing.
      Parameters:
      sku - the Stock Keeping Unit identifier for this Product. Typically only set this if intending to sell this single Product in the store, but can also be set to the same value as a related variant's sku to declare a default variant/default sku for the product
    • setUpc

      public void setUpc(String upc)
      Universal product code that identifies this product. This is usually only relevant when this product is sold individually without any variants
      Parameters:
      upc - a Universal Product Code to describe this Product
    • setExternalId

      public void setExternalId(String externalId)
      This is an arbitrary ID, typically assigned by or used by 1st or 3rd party systems that are not Broadleaf.
      Parameters:
      externalId - an external ID, often a DB or business ID, from a system outside of Broadleaf
    • setCurrency

      public void setCurrency(javax.money.CurrencyUnit currency)
      Currency for all of the prices on this product
      Specified by:
      setCurrency in interface com.broadleafcommerce.money.CurrencyConsumer
      Parameters:
      currency - the currency to use for all of the prices on this product
    • setPricingKey

      public void setPricingKey(String pricingKey)
      System-wide unique identifier to configure specific pricing for the product. Relevant if pricing data is managed in a separate system or data store, like the Broadleaf pricing services.
      Parameters:
      pricingKey - a unique key to identify this product (usually a UUID)
    • setMsrp

      public void setMsrp(javax.money.MonetaryAmount msrp)
      Suggested retail price for the product. This is generally only used for display and should not have any true pricing logic tied to it.
      Parameters:
      msrp - what to display as the suggested retail price
      See Also:
      • currency
    • setDefaultPrice

      public void setDefaultPrice(javax.money.MonetaryAmount defaultPrice)

      The default price that should be used if there is not a salePrice set. This price can also be used as the default price for all of the Variants as well.

      For more advance pricing calculations, consider hiding this field in the API and removing support for it in lieu of managing prices outside of this service.

      Always included in the API even if set to null to indicate whether or not this was explicitly set

      Parameters:
      defaultPrice - the main price used for this particular Product, only applicable if sellable in the store
    • setSalePrice

      public void setSalePrice(javax.money.MonetaryAmount salePrice)
      Indicates that this product is on sale. This should take priority over the default price if this salePrice is lower than the defaultPrice.
      Parameters:
      salePrice - the sale price, indicating that the product is on sale
    • setCost

      public void setCost(javax.money.MonetaryAmount cost)
      Can be used in display or as a part of more complex pricing algorithms.
      Parameters:
      cost - the cost of this product
    • setMetaTitle

      public void setMetaTitle(String metaTitle)
      Used for SEO data in <title> tag in a product detail page. If this is unset, the name should be used.
      Parameters:
      metaTitle - the meta title used for SEO data in product details page title
    • setMetaDescription

      public void setMetaDescription(String metaDescription)
      Used for SEO data in <meta description=""> in a product detail page. If this is unset, the description should be used
      Parameters:
      metaDescription - the meta description used for SEO data in product details page description
    • setDisplayTemplate

      public void setDisplayTemplate(String displayTemplate)
      Defines the display template. The display template can be used to help create a unique key that drives the presentation layer destination for this category. For example, if using Spring MVC with Thymeleaf, this could be a path to a Thymeleaf template. If using a frontend view technology like React, this could point to a specific React component.
      Parameters:
      displayTemplate - the display template to use for this product
    • setOnline

      public void setOnline(boolean online)

      Whether or not this product should be visible at all in the store. A product that is offline is not searchable, visible, or purchasable. A product that is offline behaves as if it falls outside the active date range. It is not returned from storefront requests by default.

      Defaults to true

      Parameters:
      online - whether or not this product is visible in the store
    • setDiscountable

      public void setDiscountable(boolean discountable)

      Whether or not this product be applied to any offers or promotions.

      Defaults to true

      Parameters:
      discountable - whether or not this product can be applied to any offers or promotions
    • setInventoryType

      public void setInventoryType(String inventoryType)
      Describes the product's type of fulfillment - ie is it a physical or virtual item?

      Defaults to InventoryType.PHYSICAL

      Parameters:
      inventoryType - a String representation of InventoryType
      See Also:
    • setMergingType

      public void setMergingType(String mergingType)
      Determines how this Product should merge with other similar items when it gets added to a cart. This will override the global setting on item merging. Out of box supported values are those in DefaultMergingType.
      Parameters:
      mergingType - the merging type to use for this Product
    • setAvailableOnline

      public void setAvailableOnline(boolean availableOnline)
      Whether or not this product is available online - ie inventory is available somewhere to fulfill this product.

      Defaults to true

      Parameters:
      availableOnline - Whether or not this product is available online.
    • setInventoryCheckStrategy

      public void setInventoryCheckStrategy(String inventoryCheckStrategy)
      Describes when the product's inventory should be checked for availability.
      Parameters:
      inventoryCheckStrategy - a String representation of InventoryCheckStrategy
      See Also:
    • setInventoryReservationStrategy

      public void setInventoryReservationStrategy(String inventoryReservationStrategy)
      Describes when the product's inventory should be reserved.
      Parameters:
      inventoryReservationStrategy - a String representation of InventoryReservationStrategy
      See Also:
    • setEligibleForPickup

      public void setEligibleForPickup(boolean eligibleForPickup)
      Whether or not this Product can be picked up at a store rather than just be shipped
      Parameters:
      eligibleForPickup - flag that denotes whether or not this product can be picked up, only applicable for InventoryType.PHYSICAL items
    • setFulfillmentFlatRates

      public void setFulfillmentFlatRates(Map<String,FulfillmentFlatRate> fulfillmentFlatRates)
      A map of flat rates for fulfilling (e.g., shipping) this product for a particular fulfillment option type (e.g., standard shipping). Depending on if the option is configured to use flat rates, this flat rate will be used in calculating the cost of fulfilling this product.

      The key of the map is the type of the fulfillment option such as FIXED_STANDARD or BANDED_PRICE_EXPRESS.

      Parameters:
      fulfillmentFlatRates - Map of Fulfillment option types to flat rates for this product.
      See Also:
    • setActiveStartDate

      public void setActiveStartDate(Instant activeStartDate)
      Start of when this product should be active.
      Parameters:
      activeStartDate - the date when this product should start being active
    • setActiveEndDate

      public void setActiveEndDate(Instant activeEndDate)
      End when this product is not longer active. Unset indicates that it is always active.
      Parameters:
      activeEndDate - the date when this product should no longer be active
      See Also:
    • setDimension

      public void setDimension(Dimensions dimension)
      Parameters:
      dimension - the dimensions of this product
    • setWeight

      public void setWeight(Weight weight)
      Parameters:
      weight - the weight of this product
    • setSearchable

      public void setSearchable(boolean searchable)

      Whether or not this product shows up in search. Usually this matches whether or not the product is individuallySold

      This defaults to true

      Parameters:
      searchable - whether or not this product shows up in search
    • setIndividuallySold

      public void setIndividuallySold(boolean individuallySold)

      If this product or any of its variants can be sold individually in the store, or if they must be apart of another product as an add-on. Usually if a product is not individually sold then it should also not show up in search.

      This defaults to true.

      Parameters:
      individuallySold - whether or not this product or any of its variants can be sold individually
      See Also:
      • searchable
    • setMerchandisingProduct

      @Deprecated public void setMerchandisingProduct(boolean merchandisingProduct)
      Deprecated.
      please use productType instead.
      This product is not sold itself, but is a sort of container for subordinate items. This allows for configurable products with different user choices through ProductOption
      Parameters:
      merchandisingProduct - whether or not this is a container, merchandised-only product
    • setProductType

      public void setProductType(String productType)
      Defines the type of the product. This affects how the product is displayed and managed in the admin UI, how it is handled by cart and order operations, and how it gets indexed by Search Services. The default types are defined by DefaultProductType.
      Parameters:
      productType - The type of the product
      See Also:
    • setBusinessType

      public void setBusinessType(String businessType)
      Defines the type of the product for business purposes. This affects how the product is displayed and managed in the admin UI.
      Parameters:
      businessType - The type of the product for business purposes
    • setKeywords

      public void setKeywords(List<String> keywords)
      Generally additional search terms that should be used when customers search for this product.
      Parameters:
      keywords - additional search terms that should be used when customers search for this product
    • setAttributes

      public void setAttributes(Map<String,Attribute> attributes)
      Dynamic attributes that are a part of the product. This is an admin-centered concept
      Parameters:
      attributes - dynamic attributes that are a part of the product
    • setIncludedProducts

      public void setIncludedProducts(List<IncludedProduct> includedProducts)

      Additional products that are always included with the product, no matter what. Used to configure "bundles" or "kits".

      If some of these items should be optional or the user should decide which additional items are added to their cart, use options instead.

      Parameters:
      includedProducts - that bundle with this product as their parent
      See Also:
    • setOptions

      public void setOptions(List<ProductOption> options)
      Drives additional information that the customer should enter when purchasing this product. This can be in the form of additional variations, additional items that can be bundled with this product or simply more information that the customer needs to enter about what they are purchasing (like a personalized message).
      Parameters:
      options - the options for this product
    • setReviewsSummary

      public void setReviewsSummary(ReviewsSummary reviewsSummary)
      The summary of reviews for this product.
      Parameters:
      reviewsSummary - The summary of reviews for this product.
    • setPrimaryAsset

      public void setPrimaryAsset(ProductAsset primaryAsset)
      The ProductAsset associated with this product marked as ProductAsset.isPrimary(). By default, this is only hydrated for API callers.
      Parameters:
      primaryAsset - The primary ProductAsset for this product.
    • setPrimaryCategory

      public void setPrimaryCategory(@Nullable Category primaryCategory)
      The Category associated with this product where the CategoryProduct relationship is marked as CategoryProduct.isPrimary().

      This field is not persisted on the product - instead, this is a dynamically set/hydrated value for API callers to conveniently manage the primary CategoryProduct relationship as part of Product API create/replace calls.

      It is not necessarily respected or hydrated in all scenarios.

      Parameters:
      primaryCategory - the category that should be associated with this product as the primary category
      See Also:
    • setTags

      public void setTags(List<String> tags)
      A list of simple labels used to categorize the product
      Parameters:
      tags - a list of simple labels used to categorize the product
    • setBrand

      public void setBrand(@Nullable DataDrivenEnum brand)
      Parameters:
      brand - the brand of this product
    • setMerchandisingType

      public void setMerchandisingType(@Nullable DataDrivenEnum merchandisingType)
      Parameters:
      merchandisingType - the merchandising type of this product
    • setTargetDemographic

      public void setTargetDemographic(@Nullable DataDrivenEnum targetDemographic)
      Parameters:
      targetDemographic - the target demographic of this product
    • setContextState

      public void setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      setContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Parameters:
      contextState - a subset of Tracking information to expose the context state for this object
    • setTaxCode

      public void setTaxCode(String taxCode)
      The tax code for this product.
      Parameters:
      taxCode - The tax code for this product.
    • setMinimumThreshold

      public void setMinimumThreshold(Integer minimumThreshold)
      The minimum count of this product that must be added in a cart.
      Parameters:
      minimumThreshold - the minimum count of this product that must be added in a cart
    • setMaximumThreshold

      public void setMaximumThreshold(Integer maximumThreshold)
      The maximum count of this product that must be added in a cart.
      Parameters:
      maximumThreshold - the maximum count of this product that must be added in a cart
    • setDefaultVariant

      public void setDefaultVariant(Variant defaultVariant)
      When the `productType` is `VARIANT_BASED` this represents the default.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object