public class ExcludeItemsInCartFilter extends CachedCollectionFilter
This filter is useful for filtering upsell products or related products etc. to prevent promoting a product that is already in the cart.
It is strongly recommended that cache not be enabled for this filter because the contents on the shopping cart can change frequently. To enable cache would require that the cache contents, for a given order, be cleared each time a product is either added or removed.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION |
protected CatalogTools |
mCatalogTools |
protected java.lang.String |
mShoppingCartPath |
FILTER_CACHE_COMPONENT, mCache, mCacheEnabled
SERVICE_INFO_KEY
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
ExcludeItemsInCartFilter() |
Modifier and Type | Method and Description |
---|---|
protected java.util.Collection |
createProductIdCollection(Order pOrder)
This method creates a collection of product ids.
|
protected java.lang.String |
findCommerceItemProductId(CommerceItem pCommerceItem)
This method returns the product id associated with a commerce item.
|
Order |
findOrder()
Finds the current order using the nucleus specified by
the shoppginCartPath property.
|
java.lang.Object |
generateContextKey(java.util.Collection pUnfilteredCollection,
java.lang.String pCollectionIdentifierKey,
RepositoryItem pProfile)
Generates a context key for this filter.
|
protected java.util.Collection |
generateFilteredCollection(java.util.Collection pUnfilteredCollection,
java.lang.String pCollectionIdentifierKey,
RepositoryItem pProfile)
Generates a filtered collection based on the products in the current order.
|
CatalogTools |
getCatalogTools()
Returns the CatalogTools
|
java.lang.String |
getShoppingCartPath()
Returns property ShoppingCartPath
|
void |
setCatalogTools(CatalogTools pCatalogTools)
Sets the CatalogTools
|
void |
setShoppingCartPath(java.lang.String pShoppingCartPath)
Sets property ShoppingCartPath
|
boolean |
shouldApplyFilter(java.util.Collection pUnfilteredCollection,
java.lang.String pKey,
RepositoryItem pProfile)
This method is called by filterCollection prior to looking up the filtered collection in the
cache or generating a new filtered collection.
|
dumpCache, filterCollection, filterCollection, filterCollection, filterCollection, flushCache, generateCacheKey, generateCacheKey, generateContextKey, generateFilteredCollection, generateNewCollectionObject, getCache, getDefaultProfile, isCacheEnabled, setCache, setCacheEnabled, shouldApplyFilter, stringIt
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
public static final java.lang.String CLASS_VERSION
protected java.lang.String mShoppingCartPath
protected CatalogTools mCatalogTools
public void setShoppingCartPath(java.lang.String pShoppingCartPath)
public java.lang.String getShoppingCartPath()
public void setCatalogTools(CatalogTools pCatalogTools)
public CatalogTools getCatalogTools()
public Order findOrder()
public java.lang.Object generateContextKey(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile)
generateContextKey
in class CachedCollectionFilter
pUnfilteredCollection
- the collection to be filteredpCollectionIdentifierKey
- the key that uniquely identifies the unfiltered collection.public boolean shouldApplyFilter(java.util.Collection pUnfilteredCollection, java.lang.String pKey, RepositoryItem pProfile)
CachedCollectionFilter
shouldApplyFilter
in class CachedCollectionFilter
pUnfilteredCollection
- the unfiltered collectionpKey
- the key param as passed to filterCollectionpProfile
- the user profileCachedCollectionFilter.shouldApplyFilter(java.util.Collection, java.lang.String, atg.repository.RepositoryItem)
protected java.lang.String findCommerceItemProductId(CommerceItem pCommerceItem)
protected java.util.Collection createProductIdCollection(Order pOrder)
pOrder
- the orderprotected java.util.Collection generateFilteredCollection(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile) throws FilterException
Products in the unfiltered collection that are in the current order are excluded from the filtered results.
If the new filtered collection is the same size as the unfiltered collection, the filtered collection is disgarded and the unfiltered collection is returned.
generateFilteredCollection
in class CachedCollectionFilter
pUnfilteredCollection
- the unfiltered collectionpCollectionIdentifierKey
- the key the uniquely identifies the unfiltered collection.pProfile
- Repository itemFilterException