Class Variant
java.lang.Object
com.broadleafcommerce.catalog.domain.product.Variant
- All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ChangeContainerOverridable
,com.broadleafcommerce.data.tracking.core.ContextStateAware
,Serializable
public class Variant
extends Object
implements Serializable, com.broadleafcommerce.data.tracking.core.ContextStateAware, com.broadleafcommerce.data.tracking.core.ChangeContainerOverridable
Variants can help further identify the specifics of a Product by narrowing down the Sku via additional user data.
Variants are only intended to be accessed within the context of a Product
and only
provide a link to the Product
it is apart of because of this.
- Author:
- Phillip Verheyden (phillipuniverse)
- See Also:
-
Constructor Summary
ConstructorDescriptionVariant()
Variant
(String id, String sku, String upc, String externalId, String name, String description, Instant activeStartDate, Instant activeEndDate, javax.money.MonetaryAmount defaultPrice, javax.money.MonetaryAmount salePrice, javax.money.MonetaryAmount cost, Dimensions dimension, Weight weight, boolean online, boolean discountable, String productId, Map<String, String> optionValues, String inventoryCheckStrategy, String inventoryReservationStrategy, ReviewsSummary reviewsSummary, Integer minimumThreshold, Integer maximumThreshold, Map<String, FulfillmentFlatRate> fulfillmentFlatRates, Map<String, Attribute> attributes, com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState, String taxCode, com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer overrideChangeContainer) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
boolean
When this Variant should no longer be active.When this Variant should start to become active.<T> T
getAttribute
(String name) Dynamic attributes that are a part of the variant.com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState
A subset ofTracking
information to expose the context state for this object.javax.money.MonetaryAmount
getCost()
Can be used in display or as apart of more complex pricing algorithmsjavax.money.MonetaryAmount
The default price that should be used if there is not asalePrice
set.Description of the Variant that can include HTML in implementations where a WYSIWYG editor manages this field.This is an arbitrary ID, typically assigned by or used by 1st or 3rd party systems that are not Broadleaf.A map of flat rates for fulfilling (e.g., shipping) this variant for a particular fulfillment option type (e.g., standard shipping).getId()
The unique identifier for this variant.Describes when the variant's inventory should be checked for availability.Describes when the variant's inventory should be reserved.The maximum count of this variant can be added in a cart.The minimum count of this variant that must be added in a cart.getName()
The name of this particular variant of the product.Helper to make this particular variant uniquely identifiable across multiple variants for the same product.com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer
The link to the product that this variant is a part ofThesummary of reviews
for this variant.javax.money.MonetaryAmount
Indicates that this product is on sale.getSku()
Sku code for this particular variant.The tax code for this variant.getUpc()
Universal product code that defines this particular variant of the productint
hashCode()
boolean
isActive()
Inactive variants are determined at runtime whether or notboolean
Whether or not this variant can participate in offers or promotionsboolean
isOnline()
Indicates whether or not this variant should appear in search or be able to be orderedisActive()
boolean
isOnSale()
An item is on sale if bothgetDefaultPrice()
andgetSalePrice()
are both setvoid
setActiveEndDate
(Instant activeEndDate) When this Variant should no longer be active.void
setActiveStartDate
(Instant activeStartDate) When this Variant should start to become active.void
setAttributes
(Map<String, Attribute> attributes) Dynamic attributes that are a part of the variant.void
setContextState
(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState) A subset ofTracking
information to expose the context state for this object.void
setCost
(javax.money.MonetaryAmount cost) Can be used in display or as apart of more complex pricing algorithmsvoid
setDefaultPrice
(javax.money.MonetaryAmount defaultPrice) The default price that should be used if there is not asalePrice
set.void
setDescription
(String description) Description of the Variant that can include HTML in implementations where a WYSIWYG editor manages this field.void
setDimension
(Dimensions dimension) void
setDiscountable
(boolean discountable) Whether or not this variant can participate in offers or promotionsvoid
setExternalId
(String externalId) This is an arbitrary ID, typically assigned by or used by 1st or 3rd party systems that are not Broadleaf.void
setFulfillmentFlatRates
(Map<String, FulfillmentFlatRate> fulfillmentFlatRates) A map of flat rates for fulfilling (e.g., shipping) this variant for a particular fulfillment option type (e.g., standard shipping).void
The unique identifier for this variant.void
setInventoryCheckStrategy
(String inventoryCheckStrategy) Describes when the variant's inventory should be checked for availability.void
setInventoryReservationStrategy
(String inventoryReservationStrategy) Describes when the variant's inventory should be reserved.void
setMaximumThreshold
(Integer maximumThreshold) The maximum count of this variant can be added in a cart.void
setMinimumThreshold
(Integer minimumThreshold) The minimum count of this variant that must be added in a cart.void
The name of this particular variant of the product.void
setOnline
(boolean online) Indicates whether or not this variant should appear in search or be able to be orderedisActive()
void
setOptionValues
(Map<String, String> optionValues) Helper to make this particular variant uniquely identifiable across multiple variants for the same product.void
setOverrideChangeContainer
(com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer overrideChangeContainer) void
setProductId
(String productId) The link to the product that this variant is a part ofvoid
setReviewsSummary
(ReviewsSummary reviewsSummary) Thesummary of reviews
for this variant.void
setSalePrice
(javax.money.MonetaryAmount salePrice) Indicates that this product is on sale.void
Sku code for this particular variant.void
setTaxCode
(String taxCode) The tax code for this variant.void
Universal product code that defines this particular variant of the productvoid
toString()
-
Constructor Details
-
Variant
public Variant(String id, String sku, String upc, String externalId, String name, String description, Instant activeStartDate, Instant activeEndDate, javax.money.MonetaryAmount defaultPrice, javax.money.MonetaryAmount salePrice, javax.money.MonetaryAmount cost, Dimensions dimension, Weight weight, boolean online, boolean discountable, String productId, Map<String, String> optionValues, String inventoryCheckStrategy, String inventoryReservationStrategy, ReviewsSummary reviewsSummary, Integer minimumThreshold, Integer maximumThreshold, Map<String, FulfillmentFlatRate> fulfillmentFlatRates, Map<String, Attribute> attributes, com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState, String taxCode, com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer overrideChangeContainer) -
Variant
public Variant()
-
-
Method Details
-
getAttribute
-
isActive
public boolean isActive()Inactive variants are determined at runtime whether or not- Returns:
- whether or not this variant is active
-
isOnSale
public boolean isOnSale()An item is on sale if bothgetDefaultPrice()
andgetSalePrice()
are both set- Returns:
- whether or not the item is on sale
-
getId
The unique identifier for this variant.- Returns:
- the context ID of the variant
-
getSku
Sku code for this particular variant. Overrides the main Product Sku that is set, if any- Returns:
- the SKU code for this variant
-
getUpc
Universal product code that defines this particular variant of the product- Returns:
- the universal product code for this variant
-
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
-
getName
The name of this particular variant of the product. Generally serves as an overridable field from a product. During option selection when narrowing the specific Sku to order- Returns:
- the name of this variant
-
getDescription
Description of the Variant that can include HTML in implementations where a WYSIWYG editor manages this field.- Returns:
- the description of this Variant, can contain HTML
-
getActiveStartDate
When this Variant should start to become active. Unset to mark this Variant as always active- Returns:
- the date on which this variant should become active
- See Also:
-
getActiveEndDate
When this Variant should no longer be active. Unset to mark this variant as never inactive- Returns:
- the date on which this variant should stop being active
- See Also:
-
getDefaultPrice
public javax.money.MonetaryAmount getDefaultPrice()The default price that should be used if there is not asalePrice
set. This price can also be maintained at the Product level- Returns:
- the default price to be used for this variant
-
getSalePrice
public javax.money.MonetaryAmount getSalePrice()Indicates that this product is on sale. This should take priority over the default price if the default price is lower- Returns:
- the sale price of this variant, indicating it is on sale
-
getCost
public javax.money.MonetaryAmount getCost()Can be used in display or as apart of more complex pricing algorithms- Returns:
- the cost of this variant
-
getDimension
- Returns:
- the dimensions of this variant
-
getWeight
- Returns:
- the weight of this variant
-
isOnline
public boolean isOnline()Indicates whether or not this variant should appear in search or be able to be orderedisActive()
- Returns:
- whether or not this variant is visible in the store
-
isDiscountable
public boolean isDiscountable()Whether or not this variant can participate in offers or promotions- Returns:
- whether or not this variant can participate in offers or promotions
-
getProductId
The link to the product that this variant is a part of- Returns:
- the context ID of the product that this variant is associated with
-
getOptionValues
Helper to make this particular variant uniquely identifiable across multiple variants for the same product. Keys correspond toAttributeChoice.attributeName
while values correspond to one of the correspondingAttributeChoice.allowedValues
.- Returns:
- a map of
option attribute names
to a correspondingoption value
-
getInventoryCheckStrategy
Describes when the variant's inventory should be checked for availability. If not set, defaults toProduct.inventoryCheckStrategy
.- Returns:
- the variant's inventory check strategy
- See Also:
-
getInventoryReservationStrategy
Describes when the variant's inventory should be reserved. If not set, defaults toProduct.inventoryReservationStrategy
.- Returns:
- the variant's inventory reservation strategy
- See Also:
-
getReviewsSummary
Thesummary of reviews
for this variant.- Returns:
- The
summary of reviews
for this variant.
-
getMinimumThreshold
The minimum count of this variant that must be added in a cart.- Returns:
- the minimum count of this variant that must be added in a cart
-
getMaximumThreshold
The maximum count of this variant can be added in a cart.- Returns:
- the maximum count of this variant can be added in a cart
-
getFulfillmentFlatRates
A map of flat rates for fulfilling (e.g., shipping) this variant 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 variant.The key of the map is the type of the fulfillment option such as
FIXED_STANDARD
orBANDED_PRICE_EXPRESS
.- Returns:
- Map of Fulfillment option types to flat rates for this variant.
- See Also:
-
getAttributes
Dynamic attributes that are a part of the variant. This is an admin-entered concept.- Returns:
- dynamic attributes that are a part of the variant
-
getContextState
public com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState getContextState()A subset ofTracking
information to expose the context state for this object.- Specified by:
getContextState
in interfacecom.broadleafcommerce.data.tracking.core.ContextStateAware
- Returns:
- a subset of
Tracking
information to expose the context state for this object
-
getTaxCode
The tax code for this variant.- Returns:
- The tax code for this variant.
-
getOverrideChangeContainer
public com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer getOverrideChangeContainer()- Specified by:
getOverrideChangeContainer
in interfacecom.broadleafcommerce.data.tracking.core.ChangeContainerOverridable
-
setId
The unique identifier for this variant.- Parameters:
id
- the context ID of the variant
-
setSku
Sku code for this particular variant. Overrides the main Product Sku that is set, if any- Parameters:
sku
- the SKU code for this variant
-
setUpc
Universal product code that defines this particular variant of the product- Parameters:
upc
- the universal product code for this variant
-
setExternalId
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
-
setName
The name of this particular variant of the product. Generally serves as an overridable field from a product. During option selection when narrowing the specific Sku to order- Parameters:
name
- the name of this variant
-
setDescription
Description of the Variant that can include HTML in implementations where a WYSIWYG editor manages this field.- Parameters:
description
- of this Variant with HTML if necessary
-
setActiveStartDate
When this Variant should start to become active. Unset to mark this Variant as always active- Parameters:
activeStartDate
- the date on which this variant should become active- See Also:
-
setActiveEndDate
When this Variant should no longer be active. Unset to mark this variant as never inactive- Parameters:
activeEndDate
- the date on which this variant should stop being active- See Also:
-
setDefaultPrice
public void setDefaultPrice(javax.money.MonetaryAmount defaultPrice) The default price that should be used if there is not asalePrice
set. This price can also be maintained at the Product level- Parameters:
defaultPrice
- the default price to be used for this variant
-
setSalePrice
public void setSalePrice(javax.money.MonetaryAmount salePrice) Indicates that this product is on sale. This should take priority over the default price if the default price is lower- Parameters:
salePrice
- the sale price of this variant, indicating it is on sale
-
setCost
public void setCost(javax.money.MonetaryAmount cost) Can be used in display or as apart of more complex pricing algorithms- Parameters:
cost
- the cost of this variant
-
setDimension
- Parameters:
dimension
- the dimensions of this variant
-
setWeight
- Parameters:
weight
- the weight of this variant
-
setOnline
public void setOnline(boolean online) Indicates whether or not this variant should appear in search or be able to be orderedisActive()
- Parameters:
online
- whether or not this variant is visible in the store
-
setDiscountable
public void setDiscountable(boolean discountable) Whether or not this variant can participate in offers or promotions- Parameters:
discountable
- whether or not this variant can participate in offers or promotions
-
setProductId
The link to the product that this variant is a part of- Parameters:
productId
- the context ID of the product that this variant is associated with
-
setOptionValues
Helper to make this particular variant uniquely identifiable across multiple variants for the same product. Keys correspond toAttributeChoice.attributeName
while values correspond to one of the correspondingAttributeChoice.allowedValues
.- Parameters:
optionValues
- a map ofoption attribute names
to a correspondingoption value
-
setInventoryCheckStrategy
Describes when the variant's inventory should be checked for availability. If not set, defaults toProduct.inventoryCheckStrategy
.- Parameters:
inventoryCheckStrategy
- a String representation ofInventoryCheckStrategy
- See Also:
-
setInventoryReservationStrategy
Describes when the variant's inventory should be reserved. If not set, defaults toProduct.inventoryReservationStrategy
.- Parameters:
inventoryReservationStrategy
- a String representation ofInventoryReservationStrategy
- See Also:
-
setReviewsSummary
Thesummary of reviews
for this variant.- Parameters:
reviewsSummary
- Thesummary of reviews
for this variant.
-
setMinimumThreshold
The minimum count of this variant that must be added in a cart.- Parameters:
minimumThreshold
- the minimum count of this variant that must be added in a cart
-
setMaximumThreshold
The maximum count of this variant can be added in a cart.- Parameters:
maximumThreshold
- the maximum count of this variant can be added in a cart
-
setFulfillmentFlatRates
A map of flat rates for fulfilling (e.g., shipping) this variant 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 variant.The key of the map is the type of the fulfillment option such as
FIXED_STANDARD
orBANDED_PRICE_EXPRESS
.- Parameters:
fulfillmentFlatRates
- Map of Fulfillment option types to flat rates for this variant.- See Also:
-
setAttributes
Dynamic attributes that are a part of the variant. This is an admin-entered concept.- Parameters:
attributes
- dynamic attributes that are a part of the variant
-
setContextState
public void setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState) A subset ofTracking
information to expose the context state for this object.- Specified by:
setContextState
in interfacecom.broadleafcommerce.data.tracking.core.ContextStateAware
- Parameters:
contextState
- a subset ofTracking
information to expose the context state for this object
-
setTaxCode
The tax code for this variant.- Parameters:
taxCode
- The tax code for this variant.
-
setOverrideChangeContainer
public void setOverrideChangeContainer(com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer overrideChangeContainer) - Specified by:
setOverrideChangeContainer
in interfacecom.broadleafcommerce.data.tracking.core.ChangeContainerOverridable
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-