Commerce Reference Store includes functionality that allows you to filter the list of recently viewed products so that you display only those products that are appropriate for the customer’s site context in the Recently Viewed panel. In a multisite environment, any time you retrieve a collection of recently viewed products by referring to the customer’s recentlyViewedProducts
profile property, you get back an unfiltered list that may contain products from multiple sites. To limit recently viewed product display to only those products that are appropriate for the site context, you must filter out any products affiliated with sites that are outside of the current site context.
Filtering Components
Two components facilitate the filtering of recently viewed products:
The
/atg/store/droplet/RecentlyViewedFilterDroplet
calls theRecentlyViewedFilter
component to filter the recently viewed products and then renders the filtered results.The
/atg/registry/CollectionFilters/RecentlyViewedFilter
component filters collections of recently viewed products. It returns only those products that are appropriate for the site context.
The RecentlyViewedFilterDroplet
is a globally-scoped instance of the class atg.service.collections.filter.droplet.CollectionFilter
designed to render a filtered set of recently viewed products. It has the properties shown in the table below:
Property | Description |
---|---|
| Properties required for enabling the caching of filtered collections. See the ATG Personalization Programming Guide for more information. |
| A comma-separated list that identifies the additional parameters that a JSP can specify as input parameters to
|
| A reference to the |
RecentlyViewedFilter
is a globally-scoped component of class atg.projects.store.collections.filter.RecentlyViewedFilter
. This class extends the generic collection filtering class atg.service.collections.filter.CachedCollectionFilter
by overriding the generateFilteredCollection()
method to take site scope into consideration when filtering recently viewed products. The generateFilterCollection()
method also filters the recently viewed products according to any size
or exclude
parameters that have been passed in through the RecentlyViewedFilterDroplet
. The RecentlyViewedFilter
component has the properties shown in the table below:
Property | Description |
---|---|
| A reference to the utility component |
| An |
| A reference to the utility component |
| A reference to the utility component |
| A reference to the utility component |
Filtering Process
RecentlyViewedFilter
iterates over each product in the customer’s recentlyViewedProducts
property, starting with the most recently viewed product first. The first filtering operation determines if the product being evaluated has been explicitly excluded. If so, RecentlyViewedFilter
omits the product from the filtered collection. Next, RecentlyViewedFilter
takes into account the RecentlyViewedTools.siteScope
property to do additional filtering:
If the
siteScope
setting iscurrent
,RecentlyViewedFilter
compares thesiteId
for the recently viewed product being evaluated to the current site ID. If they match, the product is added to the filtered collection.If the
siteScope
setting is a shareable type ID,RecentlyViewedFilter
retrieves a list of IDs for any sites that are in a sharing group with the current site, as defined by the shareable type ID (for example, the list of sites that share a shopping cart with the current site).RecentlyViewedFilter
then compares thesiteId
for the recently viewed product being evaluated to the site IDs it retrieved. If there is a match, the product is added to the filtered collection.Note that this is the type of filtering Commerce Reference Store uses. Commerce Reference Store sets the
RecentlyViewedTools.siteScope
setting toatg.ShoppingCart
, so the customer will see recently viewed products from the current site and any sites that share a shopping cart with the current site. For example, a customer viewing ATG Store US would see recently viewed products from ATG Store US and ATG Home, but not from ATG Store Germany.If the
siteScope
setting isall
, all recently viewed products are added to the filtered collection, regardless of site ID (in other words, no products are filtered out).
RecentlyViewedFilter
performs two additional tests when determining if a recently viewed product should be included in the filtered collection. If the site the product was originally viewed on is disabled or unavailable, the product is omitted. Also, if the product no longer exists, it is omitted from the filtered collection. When filtering is complete, the filtered collection is returned to RecentlyViewedFilterDroplet
for rendering.
Note: With a RecentlyViewedTools.siteScope
setting of all
, all recently viewed products are always returned and no filtering occurs, so there is no need to use a recently viewed product filter unless you are using a siteScope
other than all
.