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

public class Category extends Object implements Serializable, com.broadleafcommerce.data.tracking.core.ContextStateAware
Categories provide a way to group related Products for merchandising, marketing, and search results. It has a URL customers can navigate to to browse its contents as well as additional SEO related fields like a meta title and description. A Category can also have related sub-categories.
Author:
Samarth Dhruva (samarthd)
See Also:
  • Constructor Details

  • Method Details

    • getId

      public String getId()
      The context ID of the category.
      Returns:
      the context ID of the category
    • getName

      public String getName()
      The name of the category.
      Returns:
      the name of the category
    • getUrl

      public String getUrl()
      SEO-friendly URL to identify this category. This is usually generated with some URL-safe version of the name of the category.

      A null URL indicates that this category should generally be hidden everywhere on the frontend and represents a backend-only categorization.

      Returns:
      the uniquely identifiable URL of this category
    • getExternalId

      public String getExternalId()
      Intended to hold any unique identifier not tied to datastore where this category is stored. For example, many implementations may integrate or import/export data from other systems that manage their own unique identifiers.
      Returns:
      a unique identifier for this category in another system
    • getDescription

      public String getDescription()
      HTML-formatted description of the category.
      Returns:
      the HTML-formatted description of the category
    • getTaxCode

      public String getTaxCode()
      The tax code for all products in this category.
      Returns:
      the tax code of the category
    • getActiveStartDate

      @Nullable public Instant getActiveStartDate()
      Defines the beginning time for which this category is active. If both the active start date and the active end date are null, this category is considered to always be active.
      Returns:
      the beginning time for which this category is active
      See Also:
    • getActiveEndDate

      @Nullable public Instant getActiveEndDate()
      Defines the ending time for which this category is active. If the active start date is not null, but the active end date is, the category is considered to be active forever, starting on the start date.
      Returns:
      the ending time for which this category is active
      See Also:
    • 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 category
    • getMetaTitle

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

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

      public CategoryRef getParentCategory()
      This category's parent category.
      Returns:
      this category's parent category
    • getProductMembershipType

      public String getProductMembershipType()
      Determines how this category defines membership of its products. Valid types are found at CategoryProductMembershipType.
      Returns:
      the product membership type of the category
      See Also:
    • getProductMembershipRule

      public String getProductMembershipRule()
      The rule string used to check if a related product is a member of this category. Only applies when this category's product membership type is CategoryProductMembershipType.RULE_BASED.
      Returns:
      the expression used to evaluate a related product's membership in this category
      See Also:
    • getProductMembershipLocale

      public Locale getProductMembershipLocale()
      The locale used to check if a related product is a member of this category. Only applies when this category's product membership type is CategoryProductMembershipType.RULE_BASED. By default, this is set as the catalog locale.
      Returns:
      the locale used to evaluate a related product's membership in this category
      See Also:
    • isShowInSiteMap

      public boolean isShowInSiteMap()
      This controls whether a category should be visible on the frontend display. An example use-case for setting this to false would be a category involving a "secret specials" page which should be hidden from general navigation and search engines, but still has a valid URL that could be sent to customers.
      Returns:
      true if the category should be visible in site maps, false otherwise
    • getAttributes

      public Map<String,Attribute> getAttributes()
      Dynamic attributes that are a part of the category
      Returns:
      dynamic attributes that are a part of the category
    • 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)
      The context ID of the category.
      Parameters:
      id - the context ID of the category
    • setName

      public void setName(String name)
      The name of the category.
      Parameters:
      name - the name of the category
    • setUrl

      public void setUrl(String url)
      SEO-friendly URL to identify this category. This is usually generated with some URL-safe version of the name of the category.

      A null URL indicates that this category should generally be hidden everywhere on the frontend and represents a backend-only categorization.

      Parameters:
      url - the uniquely identifiable URL of this category
    • setExternalId

      public void setExternalId(String externalId)
      Intended to hold any unique identifier not tied to datastore where this category is stored. For example, many implementations may integrate or import/export data from other systems that manage their own unique identifiers.
      Parameters:
      externalId - a unique identifier for this category in another system
    • setDescription

      public void setDescription(String description)
      HTML-formatted description of the category.
      Parameters:
      description - the HTML-formatted description of the category
    • setTaxCode

      public void setTaxCode(String taxCode)
      The tax code for all products in this category.
      Parameters:
      taxCode - the tax code of the category
    • setActiveStartDate

      public void setActiveStartDate(@Nullable Instant activeStartDate)
      Defines the beginning time for which this category is active. If both the active start date and the active end date are null, this category is considered to always be active.
      Parameters:
      activeStartDate - the beginning time for which this category is active
      See Also:
    • setActiveEndDate

      public void setActiveEndDate(@Nullable Instant activeEndDate)
      Defines the ending time for which this category is active. If the active start date is not null, but the active end date is, the category is considered to be active forever, starting on the start date.
      Parameters:
      activeEndDate - the ending time for which this category is active
      See Also:
    • 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 category
    • setMetaTitle

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

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

      public void setParentCategory(CategoryRef parentCategory)
      This category's parent category.
      Parameters:
      parentCategory - this category's parent category
    • setProductMembershipType

      public void setProductMembershipType(String productMembershipType)
      Determines how this category defines membership of its products. Valid types are found at CategoryProductMembershipType.
      Parameters:
      productMembershipType - the product membership type of the category
      See Also:
    • setProductMembershipRule

      public void setProductMembershipRule(String productMembershipRule)
      The rule string used to check if a related product is a member of this category. Only applies when this category's product membership type is CategoryProductMembershipType.RULE_BASED.
      Parameters:
      productMembershipRule - an expression based off of Product criteria
      See Also:
    • setProductMembershipLocale

      public void setProductMembershipLocale(Locale productMembershipLocale)
      The locale used to check if a related product is a member of this category. Only applies when this category's product membership type is CategoryProductMembershipType.RULE_BASED. By default, this is set as the catalog locale.
      Parameters:
      productMembershipLocale - the locale to evaluate the membership rule
      See Also:
    • setShowInSiteMap

      public void setShowInSiteMap(boolean showInSiteMap)
      This controls whether a category should be visible on the frontend display. An example use-case for setting this to false would be a category involving a "secret specials" page which should be hidden from general navigation and search engines, but still has a valid URL that could be sent to customers.
      Parameters:
      showInSiteMap - true if the category should be visible in site maps, false otherwise
    • setAttributes

      public void setAttributes(Map<String,Attribute> attributes)
      Dynamic attributes that are a part of the category
      Parameters:
      attributes - dynamic attributes that are a part of the category
    • 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