This section describes how Commerce Reference Store detects when a product is being viewed and then adds that product to the recently viewed list.
Detecting When a Product is Being Viewed
Depending on the type of product being displayed, the product detail page may be one of three JSPs found in store.war/browse/productDetailDisplay.jsp
, productDetailMultiSkuContainer.jsp
, or productDetailSingleSkuContainer.jsp
. All three pages include the store.war/browse/gadgets/productLookupForDisplay.jsp
gadget, which calls the /atg/commerce/catalog/ProductBrowsed
component. This component dispatches a message each time a customer browses a product on the product detail page. To receive these messages, Commerce Reference Store includes a MessageSink
component called the /atg/userprofiling/recentlyviewed/RecentlyViewedHistoryCollector
.
When RecentlyViewedHistoryCollector
receives a message, it determines if the message’s type is ViewItem
and if the message’s item type is product
. If both tests are true, RecentlyViewedHistoryCollector
calls the RecentlyViewedTools
component to add the product to the customer’s recently viewed list. RecentlyViewedHistoryCollector
is a globally scoped component of class atg.projects.store.userprofiling.RecentlyViewedHistoryCollector
and it has the properties shown in the table below:
Property | Description |
---|---|
| A string that represents the JMS message type that |
| A string that represents the item type that |
| A reference to the |
| A reference to the |
In order to specify RecentlyViewedHistoryCollector
as a message sink, Commerce Reference Store adds the necessary configuration to the /atg/dynamo/messaging/dynamoMessagingSystem.xml
file.
Note: See the ATG Platform Programming Guide for more information on message sinks and the Patch Bay messaging system.
Adding a Product to the Recently Viewed List
The /atg/userprofiling/recentlyviewed/RecentlyViewedTools
component performs all the calls required to read and write information to and from the recently viewed list stored in the Profile repository. This component also includes some convenience methods for tasks such as determining if a product has expired and determining if the recently viewed list contains duplicates. The RecentlyViewedTools
component is a globally-scoped component of class atg.projects.store.userprofiling
and it has the properties shown in the table below:
Property | Description |
---|---|
| A reference to the utility component |
| An |
| An |
| This property determines the behavior of recently viewed lists in a multisite environment. There are three potential values: |
| The path to the |
In preparation for adding a product to the recently viewed list, RecentlyViewedTools
retrieves the current recently viewed list from the customer’s profile and scrubs it of any products that are out of date or no longer exist. It also creates a new recentlyViewedProduct
item with the current site’s ID and the current timestamp. This is the item that will potentially be added to the recently viewed list.
Next, RecentlyViewedTools
builds a “virtual” list of recentlyViewedProduct
items that contains only those items in the customer’s recently viewed list that are appropriate for the current site context. The items that are included are determined by the RecentlyViewedTools.siteScope
property. The size of the list is determined by the RecentlyViewedTools.recentlyViewedSize
property. The process for building virtual lists is described below:
A
siteScope
ofcurrent
dictates that there is one virtual list for each site. For example, ifsiteScope=current
andrecentlyViewedSize=10
, Commerce Reference Store would have three virtual lists—one each for ATG Store US, ATG Store Germany, and ATG Home—and each list could contain up to 10 recently viewed products. ArecentlyViewedProduct
item is included in a virtual list if it has a matching site ID; for example, the ATG Store US list includes only those items whoserecentlyViewedProduct.siteId
value isstoreSiteUS
.When the
siteScope
value is a shareable type ID, there is one list for each sharing group that is defined by the shareable type ID. Any sites that are not in a sharing group also have their own list. For example, ifsiteScope=atg.ShoppingCart
andrecentlyViewedSize=10
, Commerce Reference Store would have two virtual lists—one for ATG Store US and ATG Home, because they share a shopping cart, and a separate list for ATG Store Germany. Each list can contain up to 10 recently viewed products. ArecentlyViewedProduct
item is included in a virtual list if it has a matching site ID; for example, the ATG Store US/ATG Home list includes only those items whoserecentlyViewedProduct.siteId
value is eitherstoreSiteUS
orhomeSite
. Note that this is the configuration Commerce Reference Store uses,siteScope=atg.ShoppingCart
andrecentlyViewedSize=10
.Finally, a
siteScope
ofall
dictates that there is one list for all sites. As with the other options, the size of this list is limited to the value specified byrecentlyViewedSize
. AnyrecentlyViewedProduct
item may be included on this one recently viewed list.
After building the virtual list for the current site context, RecentlyViewedTools
determines if the new recentlyViewedProduct
has a site ID that matches one of the IDs associated with the virtual list. If so, RecentlyViewedTools
adds the recentlyViewedProduct
to the list, assuming the list limit has not been reached yet. If the virtual list is full, RecentlyViewedTools
removes one or more of the oldest recentlyViewedProduct
items to make room for the new item before adding it to the beginning of the list.
Note: RecentlyViewedTools
would only need to remove more than one item from a recently viewed list to make room for a new item if the recentlyViewedSize
value had been changed to a lower value, for example, prior to a server restart.