Class OptionTemplate

java.lang.Object
com.broadleafcommerce.catalog.domain.option.OptionTemplate
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ContextStateAware, Serializable

public class OptionTemplate extends Object implements Serializable, com.broadleafcommerce.data.tracking.core.ContextStateAware
Allows the creation of a ProductOption from this template, allowing users to avoid recreating the same option for multiple products over and over again.

Often, these are grouped into an OptionTemplateGroup to provide a sort of product type. For instance if you are selling T-Shirts, all of the T-shirts might have a product option "size" and "color", but they all have the same sizes and same colors. This might be configured with an OptionTemplateGroup of "Tshirts", that contain a 'Size' and 'Color' template, used to create products off of.

Note that by default the options generated from a template are not kept in sync with changes to the template.

Author:
Phillip Verheyden (phillipuniverse)
See Also:
  • Constructor Details

    • OptionTemplate

      public OptionTemplate(String id)
      Convenience constructor, primarily for testing to populate with an id.
      Parameters:
      id -
    • OptionTemplate

      public OptionTemplate()
  • Method Details

    • getId

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

      public String getName()
      Admin management name for this template, used to help narrow down individual templates
    • isPreferAddTemplateByReference

      public boolean isPreferAddTemplateByReference()
      Determines whether the Product.getOptions() generated from this template will reference the template. Default is embedded.
      Returns:
      true for the ProductOption to reflect changes made to the OptionTemplate, false for the generated ProductOption to hold its own copy of the template
    • getOption

      public ProductOption getOption()
      The option that this template actually manages
    • 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
    • setId

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

      public void setName(String name)
      Admin management name for this template, used to help narrow down individual templates
    • setPreferAddTemplateByReference

      public void setPreferAddTemplateByReference(boolean preferAddTemplateByReference)
      Determines whether the Product.getOptions() generated from this template will reference the template. Default is embedded.
      Parameters:
      preferAddTemplateByReference - true for the ProductOption to reflect changes made to the OptionTemplate, false for the generated ProductOption to hold its own copy of the template
    • setOption

      public void setOption(ProductOption option)
      The option that this template actually manages
    • 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
    • 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