Broadleaf Microservices
  • v1.0.0-latest-prod

Facilitating Data Driven Enum Details Sections

Overview

Catalog Services provides an endpoint to facilitate the building of data driven enum details, which is useful for pages or sections that leverage data driven enums and need to hydrate them.

For example, if we wanted to display the display value of the product’s brand in a product detail page, this endpoint can be used to hydrate the data driven enum itself, as well as checking if an associated category exist for that brand.

Tip
Reference the DataDrivenEnumDetails javadoc to see what’s included in the details.

Key Components

DataDrivenEnumDetailsEndpoint

This is the entry point for request to retrieve data driven enum details based on given id.

To see what the request and response payloads look like, please reference the OpenAPI specification this endpoint.

DataDrivenEnumDetailsService

This service is responsible for retrieving and building the data driven enum details, which includes querying the entity itself.

On top of that, if the request param checkIfAssociatedCategoryExist is true, it will also check if a category exist based on its value. Then include the result as part of the DataDrivenEnumDetails.

Tip
See the DataDrivenEnumDetails javadoc for further details.

Checking if an Associated Category Exist

If the data driven enum field is used to further categorize products, then typically a category is expected to exist to serve as a landing page for that set of products.

For example, let’s say we want to categorize products based on the product’s brand property. In this case, it would be beneficial to have a category created for that brand (i.e. /some-sauce-brand), simply for surfacing specific content (i.e. banner images, text, etc.), although it is not required.

To serve that purpose, this process will check if a category exist with the URL that follows the convention based on the data driven enum value. By default, it expects the category to have an URL of data driven enum value being lowercase and underscores(_) replaced by dashes (-). For example, if the value is SOME_SAUCE_BRAND, then it will look for a category with the URL /some-sauce-brand.

To customize the URL convention, you can simply override this service, specifically the checkAssociatedCategoryExists or DefaultDataDrivenEnumDetailsService#buildExpectedCategoryUrl methods.