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
ConstructorsConstructorDescriptionCategory()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 booleanbooleanDefines 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.ContextStateA subset ofTrackinginformation 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.inthashCode()booleanThis controls whether a category should be visible on the frontend display.voidsetActiveEndDate(Instant activeEndDate) Defines the ending time for which this category is active.voidsetActiveStartDate(Instant activeStartDate) Defines the beginning time for which this category is active.voidsetAttributes(Map<String, Attribute> attributes) Dynamic attributes that are a part of the categoryvoidsetContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState) A subset ofTrackinginformation to expose the context state for this object.voidsetDescription(String description) HTML-formatted description of the category.voidsetDisplayTemplate(String displayTemplate) Defines the display template.voidsetExternalId(String externalId) Intended to hold any unique identifier not tied to datastore where this category is stored.voidThe context ID of the category.voidsetMetaDescription(String metaDescription) Used for SEO data in<meta description="">in a category detail page.voidsetMetaTitle(String metaTitle) Used for SEO data in<title>tag in a category detail page.voidThe name of the category.voidsetParentCategory(CategoryRef parentCategory) This category's parent category.voidsetProductMembershipLocale(Locale productMembershipLocale) The locale used to check if a related product is a member of this category.voidsetProductMembershipRule(String productMembershipRule) The rule string used to check if a related product is a member of this category.voidsetProductMembershipType(String productMembershipType) Determines how this category defines membership of its products.voidsetShowInSiteMap(boolean showInSiteMap) This controls whether a category should be visible on the frontend display.voidsetTaxCode(String taxCode) The tax code for all products in this category.voidSEO-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
nullURL 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 dateare 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 dateis 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, thenameshould 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, thenameshould 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:
-
CategoryProductMembershipTypePromotionalCategoryProductgetProductMembershipRule()
-
getProductMembershipRule
The rule string used to check if a related product is a member of this category. Only applies when this category'sproduct membership typeisCategoryProductMembershipType.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 typeisCategoryProductMembershipType.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 validURLthat 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 ofTrackinginformation to expose the context state for this object.- Specified by:
getContextStatein interfacecom.broadleafcommerce.data.tracking.core.ContextStateAware- Returns:
- a subset of
Trackinginformation 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
nullURL 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 dateare 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 dateis 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, thenameshould 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, thenameshould 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:
-
CategoryProductMembershipTypePromotionalCategoryProductgetProductMembershipRule()
-
setProductMembershipRule
The rule string used to check if a related product is a member of this category. Only applies when this category'sproduct membership typeisCategoryProductMembershipType.RULE_BASED.- Parameters:
productMembershipRule- an expression based off ofProductcriteria- 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 typeisCategoryProductMembershipType.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 validURLthat 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 ofTrackinginformation to expose the context state for this object.- Specified by:
setContextStatein interfacecom.broadleafcommerce.data.tracking.core.ContextStateAware- Parameters:
contextState- a subset ofTrackinginformation to expose the context state for this object
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-