Class Name |
|
---|---|
Component(s) |
|
When given a category, product, and SKU, the ProductListContains
servlet bean queries whether a product comparison list includes the given product.
Input Parameters
productList (Required)
The ProductComparisonList
object to examine.
productID (Required)
The repository ID of the product to look for in productList
.
categoryID
The repository ID of the category to look for in productList
.
If you don’t specify a category ID, then ProductListContains
looks for a list entry whose category
property matches either the given product’s default category or null if there is no default category for the given product.
skuID
The repository ID of the SKU to look for in productList
.
If you don’t specify a SKU, then ProductListContains
looks for a list entry whose sku
property matches either the given product’s first child SKU or null if there are no SKUs for the given product.
repositoryKey
The key to pass to CatalogTools
to select a product catalog repository in which to look for the item. The key-to-catalog mapping is defined in CatalogTools
. If this parameter is unset, the default product catalog repository is used.
This optional parameter is useful for localization, which often requires the use of alternate product catalogs for different locales.
Output Parameters
None
Open Parameters
true
Rendered if the product comparison list contains the specific product, category, and SKU.
false
Rendered if the product comparison list doesn’t contain the specified product, category, and SKU.
Example
This JSP example shows how to add or remove a single product from a product comparison list. The example assumes that the ProductListContains
servlet bean is embedded in a product display page using the following:
<dsp:include page="example.jsp"><dsp:param name="product" value="current product"/></dsp:include>
where current product is an expression that provides access to the product displayed on the page.
The given product is passed into the servlet bean in the productId
input parameter. The ProductListContains
servlet bean then checks whether it is stored in the product comparison list in ProductList
.
If the product is in the product comparison list, then the servlet bean renders the true
open parameter on the product display page. The user can then click the “Remove from comparison list” submit button to remove the product from the list. If the product is not in the product comparison list, then the servlet bean renders the false
open parameter on the product display page. The user can then click the “Add to comparison list” submit button to add the product to the list.
<dsp:importbean bean="/atg/commerce/catalog/comparison/ProductList"/> <dsp:importbean bean="/atg/commerce/catalog/comparison/ProductListContains"/> <dsp:importbean bean="/atg/commerce/catalog/comparison/ProductListHandler"/> <dsp:form action="product.jsp" method="POST"> <dsp:droplet name="ProductListContains"> <dsp:param bean="ProductList" name="productList"/> <dsp:param param="product.repositoryId" name="productID"/> <dsp:oparam name="true"> <dsp:input bean="ProductListHandler.productID" paramvalue="productID" type="hidden"/> <dsp:input bean="ProductListHandler.removeProduct" value="Remove from comparison list" type="submit"/> </dsp:oparam> <dsp:oparam name="false"> <dsp:input bean="ProductListHandler.productID" paramvalue="productID" type="hidden"/> <dsp:input bean="ProductListHandler.addProduct" value="Add to comparison list" type="submit"/> </dsp:oparam> </dsp:droplet> </dsp:form>