Oracle ATG Web Commerce includes functionality that allows you to filter collections of gift lists and gift items so that you display only those lists/items that are appropriate for the customer’s site context. In a multisite environment, any time you retrieve a collection of gift lists or gift items by referring to a repository item’s property, such as Profile.giftlists
or Profile.wishlist.giftlistItems
, you get back an unfiltered list that may contain items from multiple sites. For these situations, you should consider whether the collection should be filtered or not and, if so, implement the filtering functionality described in this section.
Filtering is particularly important for wish lists. Customers can only have one wish list, making it more likely that items from multiple sites will exist in a single wish list. To limit wish list item display to only those items that are appropriate for the site context, you must filter out any items affiliated with sites that are outside of the site context.
Two components facilitate the filtering of gift lists and gift items:
The
/atg/commerce/collections/filter/droplet/GiftlistSiteFilterDroplet
calls theGiftlistSiteFilter
component to filter a specified collection of gift lists/gift items and then renders the filtered results.The
/atg/registry/CollectionFilters/GiftlistSiteFilter
component filters collections of gift lists or gift items. It returns only those lists/items that are appropriate for the site context.
The GiftlistSiteFilterDroplet
is a globally-scoped instance of the class atg.service.collections.filter.droplet.CollectionFilter
designed to render a filtered set of gift lists/gift items. It has the following properties:
filter
: Reference to the/atg/registry/CollectionFilters/GiftlistSiteFilter
component.extraParameterNames
: A comma-separated list that identifies the additional parameters, namelysiteIds
andsiteScope
, that a JSP can specify as input parameters toGiftlistSiteFilterDroplet
.GiftlistSiteFilterDroplet
passes these parameters on toGiftlistSiteFilter
so that it can filter gift lists based on site context. If the JSP doesn’t pass values for these parameters,GiftlistSiteFilter
defaults to using the current site and theGiftlistManager.siteScope
value, respectively.
GiftlistSiteFilter
is a globally-scoped component of class atg.commerce.gifts.GiftlistSiteFilter
. This class extends the generic collection filtering class atg.service.collections.filter.CachedCollectionFilter
by overriding the generateFilteredCollection()
method to take site scope and site ID parameters into consideration when filtering gift lists or gift items. GiftlistSiteFilter
resolves the site scope and site ID values as follows:
If a site scope is passed in,
GiftlistSiteFilter
uses that scope during filtering. If not,GiftlistSiteFilter
calls theGiftlistManager
and uses itssiteScope
setting for filtering. Note that, with the defaultsiteScope
setting ofall
, all gift lists/items are always returned and no filtering occurs, so you should not use gift list/item filters unless you are using asiteScope
other thanall
.If a list of site IDs is passed in,
GiftlistSiteFilter
uses that list during filtering. If no site IDs are passed in, the current site’ssiteId
is used during filtering.
When filtering gift lists, the GiftlistSiteFilter
determines the site scope and then compares the siteId
’s of the gift lists/gift items in the repository to the IDs in its list, as shown in the following table:
Compatibility Test | All | Current | ShareableType ID |
---|---|---|---|
Gift list/gift item’s | Include gift list/gift item in filtered results | Include gift list/gift item in filtered results | Include gift list/gift item |
Gift list/gift item’s | Include gift list/gift item in filtered results | Do not include gift list/gift item in filtered results | Include gift list/gift item in filtered results if the gift list/gift item’s |
Gift list/gift item’s Note: This is also the wish list case. | The gift list/item is universal and should be included in filtered results | The gift list/item is universal and should be included in filtered results | The gift list/item is universal and should be included in filtered results |
Properties for the GiftlistSiteFilter
component include:
giftlistManager
: Reference to the gift list manager component/atg/commerce/gifts/GiftlistManager
.siteGroupManager
: Reference to the site group manager component/atg/multisite/SiteGroupManager
. This component determines which sites are part of the same sharing group and can share data such as gift lists.includeDisabledSites
: Iftrue
, the filter does not filter out items that appear on disabled sites. The default isfalse
.includeInactiveSites
: Iftrue
, the filter does not filter out items that appear on inactive sites. The default isfalse
.
Note that, unlike the GiftlistSearch
form handler, the GiftlistSiteFilter
component does not have siteScope
or siteIds
properties. Instead, the site scope and list of site IDs are passed to GiftlistSiteFilter
by the GiftlistSiteFilterDroplet
, as described below.
This JSP excerpt shows one example of how you can use GiftlistSiteFilterDroplet
to filter gift lists. No site scope is passed in, so the GiftlistSiteFilter
uses the GiftlistManager
component’s siteScope
, which for the purposes of this example is set to the atg.ShoppingCart
shareable type component. Also, no site IDs are provided, so the filtered gift lists will come from the current site and sites that share a shopping cart with the current site only.
<dsp:droplet name="/atg/commerce/collections/filter/droplet/GiftlistSiteFilterDroplet"> <&-- Specify the collection to filter --%> <dsp:param name="collection" bean="Profile.giftlists"/> <dsp:oparam name="output"> <%-- Iterate through the collection. --%> <dsp:importbean bean="/atg/dynamo/droplet/ForEach"/> <dsp:droplet name="ForEach"> <dsp:param name="array" param="filteredCollection"/> <dsp:oparam name="output"> <dsp:setvalue param="giftList" paramvalue="element"/> <dsp:getvalueof var="eventName" param="giftList.eventName"/> <c:out value="${eventName}"/> </dsp:oparam> </dsp:droplet> </dsp:oparam> </dsp:droplet>
This JSP excerpt filters a collection of wish list items. A site scope value of current
is passed to the filter along with a set of site IDs, resulting in a collection of items from the specified sites only.
<dsp:droplet name="/atg/commerce/collections/filter/droplet/GiftlistSiteFilterDroplet"> <&-- Specify the collection to filter and the site scope. --%> <dsp:param name="collection" bean="Profile.wishlist.giftlistItems"/> <dsp:param name="siteScope" value="current"/> <dsp:param name="siteIds" value="siteA,siteB"/> <dsp:oparam name="output"> <%-- Iterate through the collection. --%> <dsp:importbean bean="/atg/dynamo/droplet/ForEach"/> <dsp:droplet name="ForEach"> <dsp:param name="array" param="filteredCollection"/> <dsp:oparam name="output"> <dsp:setvalue param="giftItem" paramvalue="element"/> <dsp:getvalueof var="displayName" param="giftItem.displayName"/> <c:out value="${displayName}"/> </dsp:oparam> </dsp:droplet> </dsp:oparam> </dsp:droplet>
Notes:
The
GiftlistSiteFilter
andGiftlistSiteFilterDroplet
components can be configured to use caching to improve filtering performance, just as you would for any filter based on theCollectionFilter
class. See Caching Filtered Content in the ATG Personalization Programming Guide.The
GiftlistSiteFilter
component can be used independently of theGiftlistSiteFilterDroplet
. To do so, you must pass thesiteIds
andsiteScope
values in thepExtraParameters
map when calling theGiftlistSiteFilter.generateFilteredCollection()
method (when using the droplet, the droplet creates thepExtraParameters
map before it calls theGiftlistSiteFilter
component). For more information, see the ATG Platform API Reference.