Class Category
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 Summary
ConstructorDescriptionCategory()
Category
(String id, String name, String url, String externalId, String description, String taxCode, Instant activeStartDate, Instant activeEndDate, String displayTemplate, String metaTitle, String metaDescription, CategoryRef parentCategory, String productMembershipType, String productMembershipRule, Locale productMembershipLocale, boolean showInSiteMap, Map<String, Attribute> attributes, com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
boolean
Defines the ending time for which this category is active.Defines the beginning time for which this category is active.Dynamic attributes that are a part of the categorycom.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState
A subset ofTracking
information to expose the context state for this object.HTML-formatted description of the category.Defines the display template.Intended to hold any unique identifier not tied to datastore where this category is stored.getId()
The context ID of the category.Used for SEO data in<meta description="">
in a category detail page.Used for SEO data in<title>
tag in a category detail page.getName()
The name of the category.This category's parent category.The locale used to check if a related product is a member of this category.The rule string used to check if a related product is a member of this category.Determines how this category defines membership of its products.The tax code for all products in this category.getUrl()
SEO-friendly URL to identify this category.int
hashCode()
boolean
This controls whether a category should be visible on the frontend display.void
setActiveEndDate
(Instant activeEndDate) Defines the ending time for which this category is active.void
setActiveStartDate
(Instant activeStartDate) Defines the beginning time for which this category is active.void
setAttributes
(Map<String, Attribute> attributes) Dynamic attributes that are a part of the categoryvoid
setContextState
(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState) A subset ofTracking
information to expose the context state for this object.void
setDescription
(String description) HTML-formatted description of the category.void
setDisplayTemplate
(String displayTemplate) Defines the display template.void
setExternalId
(String externalId) Intended to hold any unique identifier not tied to datastore where this category is stored.void
The context ID of the category.void
setMetaDescription
(String metaDescription) Used for SEO data in<meta description="">
in a category detail page.void
setMetaTitle
(String metaTitle) Used for SEO data in<title>
tag in a category detail page.void
The name of the category.void
setParentCategory
(CategoryRef parentCategory) This category's parent category.void
setProductMembershipLocale
(Locale productMembershipLocale) The locale used to check if a related product is a member of this category.void
setProductMembershipRule
(String productMembershipRule) The rule string used to check if a related product is a member of this category.void
setProductMembershipType
(String productMembershipType) Determines how this category defines membership of its products.void
setShowInSiteMap
(boolean showInSiteMap) This controls whether a category should be visible on the frontend display.void
setTaxCode
(String taxCode) The tax code for all products in this category.void
SEO-friendly URL to identify this category.toString()
-
Constructor Details
-
Category
public Category() -
Category
public Category(String id, String name, String url, String externalId, String description, String taxCode, @Nullable Instant activeStartDate, @Nullable Instant activeEndDate, String displayTemplate, String metaTitle, String metaDescription, CategoryRef parentCategory, String productMembershipType, String productMembershipRule, Locale productMembershipLocale, boolean showInSiteMap, Map<String, Attribute> attributes, com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
-
-
Method Details
-
getId
The context ID of the category.- Returns:
- the context ID of the category
-
getName
The name of the category.- Returns:
- the name of the category
-
getUrl
SEO-friendly URL to identify this category. This is usually generated with some URL-safe version ofthe 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
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
HTML-formatted description of the category.- Returns:
- the HTML-formatted description of the category
-
getTaxCode
The tax code for all products in this category.- Returns:
- the tax code of the category
-
getActiveStartDate
Defines the beginning time for which this category is active. If both the active start date and theactive 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
Defines the ending time for which this category is active. If theactive 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
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
Used for SEO data in<title>
tag in a category detail page. If this is unset, thename
should be used.- Returns:
- the meta title used for SEO data in category details page title
-
getMetaDescription
Used for SEO data in<meta description="">
in a category detail page. If this is unset, thename
should be used.- Returns:
- the meta description used for SEO data in category details page description
-
getParentCategory
This category's parent category.- Returns:
- this category's parent category
-
getProductMembershipType
Determines how this category defines membership of its products. Valid types are found atCategoryProductMembershipType
.- Returns:
- the product membership type of the category
- See Also:
-
CategoryProductMembershipType
PromotionalCategoryProduct
getProductMembershipRule()
-
getProductMembershipRule
The rule string used to check if a related product is a member of this category. Only applies when this category'sproduct membership type
isCategoryProductMembershipType.RULE_BASED
.- Returns:
- the expression used to evaluate a related product's membership in this category
- See Also:
-
getProductMembershipLocale
The locale used to check if a related product is a member of this category. Only applies when this category'sproduct membership type
isCategoryProductMembershipType.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 validURL
that could be sent to customers.- Returns:
- true if the category should be visible in site maps, false otherwise
-
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 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
-
setId
The context ID of the category.- Parameters:
id
- the context ID of the category
-
setName
The name of the category.- Parameters:
name
- the name of the category
-
setUrl
SEO-friendly URL to identify this category. This is usually generated with some URL-safe version ofthe 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
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
HTML-formatted description of the category.- Parameters:
description
- the HTML-formatted description of the category
-
setTaxCode
The tax code for all products in this category.- Parameters:
taxCode
- the tax code of the category
-
setActiveStartDate
Defines the beginning time for which this category is active. If both the active start date and theactive 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
Defines the ending time for which this category is active. If theactive 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
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
Used for SEO data in<title>
tag in a category detail page. If this is unset, thename
should be used.- Parameters:
metaTitle
- the meta title used for SEO data in category details page title
-
setMetaDescription
Used for SEO data in<meta description="">
in a category detail page. If this is unset, thename
should be used.- Parameters:
metaDescription
- the meta description used for SEO data in category details page description
-
setParentCategory
This category's parent category.- Parameters:
parentCategory
- this category's parent category
-
setProductMembershipType
Determines how this category defines membership of its products. Valid types are found atCategoryProductMembershipType
.- Parameters:
productMembershipType
- the product membership type of the category- See Also:
-
CategoryProductMembershipType
PromotionalCategoryProduct
getProductMembershipRule()
-
setProductMembershipRule
The rule string used to check if a related product is a member of this category. Only applies when this category'sproduct membership type
isCategoryProductMembershipType.RULE_BASED
.- Parameters:
productMembershipRule
- an expression based off ofProduct
criteria- See Also:
-
setProductMembershipLocale
The locale used to check if a related product is a member of this category. Only applies when this category'sproduct membership type
isCategoryProductMembershipType.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 validURL
that could be sent to customers.- Parameters:
showInSiteMap
- true if the category should be visible in site maps, false otherwise
-
setAttributes
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 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
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-