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 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

consultCache and updateCache

Properties required for enabling the caching of filtered collections. See the ATG Personalization Programming Guide for more information.

extraParameterNames

A comma-separated list that identifies the additional parameters that a JSP can specify as input parameters to RecentlyViewedFilterDroplet. RecentlyViewedFilterDroplet subsequently passes these parameters, as a map, to the RecentlyViewedFilter. There are two extra parameters and both are optional:

exclude: Either a string that represents a single product ID, or a list of product IDs or product repository items. Any product specified in this parameter is excluded from the filtered list.

size: An int that specifies the maximum number of products the RecentlyViewedFilter should return. This value overrides the RecentlyViewedFilter.maxProductsToDisplay property.

filter

A reference to the RecentlyViewedFilter component.

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

catalogTools

A reference to the utility component /atg/commerce/catalog/CatalogTools, used for working with catalogs.

maxProductsToDisplay

An int that specifies the maximum number of products the RecentlyViewedFilter should return. This value may be overridden by an extraParameter called size that may be passed to RecentlyViewedFilter through the RecentlyViewedFilterDroplet. Commerce Reference Store sets this value to 5.

profileTools

A reference to the utility component /atg/userprofiling/ProfileTools, used for working with user profiles.

recentlyViewedTools

A reference to the utility component RecentlyViewedTools.

siteGroupManager

A reference to the utility component /atg/multisite/SiteGroupManager, used for working with sites in a multi-site environment. RecentlyViewedFilter uses the SiteGroupManager component to check if a shareableType ID is registered and to get a list of sites that are sharing a shareableType object with the current site.

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:

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.


Copyright © 1997, 2013 Oracle and/or its affiliates. All rights reserved. Legal Notices