Several of Commerce Reference Store’s features, such as the Continue Shopping and breadcrumbs features, require knowing the most recent category a customer has browsed. To enable tracking of a customer’s catalog navigation, Commerce Reference Store implements the /atg/store/catalog/CatalogNavigation
component, of class atg.projects.store.catalog.CatalogNavigationService
. This session-based component stores information about the customer’s current category and that category’s position in the Category dimension hierarchy. The CatalogNavigation
component provides:
The ID of the current category.
The IDs of the ancestor categories for the current category.
The top-level category associated with the current category.
The full category hierarchy path from the current category up to its top-level parent.
In addition, the CatalogNavigation
component has a validateCategory()
method that applies the CollectionObjectValidator
components listed in the validators
property to the current category and stores a boolean result. By default, the validators
property is set to the /atg/store/collections/validator/StartEndDateValidator
component.
The data stored in the CatalogNavigation
component is updated each time the customer makes a request for a category page.
To determine if the request is for a category page, first the URL is parsed. This is the responsibility of the /atg/endeca/assembler/cartridge/manager/NavigationStateBuilder
component, which is of class atg.endeca.assembler.navigation.ExtendedNavigationStateBuilder
. The ExtendedNavigationStateBuilder
class is an extension of the endeca.infront.navigation.url.UrlNavigationStateBuilder
class. The UrlNavigationStateBuilder
class parses the URL and creates an initial com.endeca.infront.navigation.NavigationState
object. The ExtendedNavigationStateBuilder
class then modifies that NavigationState
object.
To specify how the NavigationState
object should be modified, the NavigationStateBuilder
component has a navigationStateProcessors
property that consists of a list of NavigationStateProcessor
components. These components must be of a class that implements the atg.endeca.assembler.navigation.NavigationStateProcessor
interface. This interface defines a process()
method that contains logic that modifies the NavigationState
object in some manner. The NavigationStateBuilder
component invokes each NavigationStateProcessor
, executing the logic contained within.
Commerce Reference Store implements a new processor component, /atg/endeca/assembler/cartridge/manager/StoreNavigationStateProcessor
, and adds it to the NavigationStateBuilder.navigationStateProcessors
property. The StoreNavigationStateProcessor
component is of class atg.projects.store.assembler.navigation.StoreNavigationStateProcessor
and it determines if the request is for a single dimension value ID. If it does, the StoreNavigationStateProcessor
component retrieves the dimension value ID from the NavigationState
object and attempts to find a match for it in the dimension value cache. If the ID exists in the cache, it indicates that this is a Category dimension value ID (as opposed to a dimension value ID from another dimension) because the cache only contains Category dimension value IDs.
If the StoreNavigationStateProcessor
component finds a match, it does the following:
It updates the
CatalogNavigation
component with the information it finds in the cache for the specified dimension value ID.It adds the
CategoryOnly
user segment to thecom.endeca.infront.navigation.UserState
object, to indicate that this is a category page request.
Categories that can be accessed via multiple paths in the Category hierarchy have multiple dimension value IDs, one for each path. Therefore, the ID that is parsed from the URL will indicate not only the Category dimension value itself, but also its hierarchical path. This ensures that when the StoreNavigationStateProcessor
component maps the dimension value ID to the category ID in the dimension value cache, it also maps to the correct hierarchy.