Model for the custom logic of the product compare feature. The implementation is bundled into a class which provides method access the compare data. The compare data itself is stored as a JSON string in the privacy attributes of the session.
Classes
Methods
(static) get() → {models/CompareModel~CompareList}
Returns the product compare list, possibly restored using JSON data from the session.
Returns:
The compare list
- Type
- models/CompareModel~CompareList
(inner) CompareList/add(p, c)
Adds a product to the set of compared products for the given category. Saves the current product comparison to the session.
Parameters:
Name | Type | Description |
---|---|---|
p |
dw.catalog.Product |
the product to add |
c |
dw.catalog.Category |
the category for which to add the object |
- Source:
- See:
(inner) CompareList/copyParentCategory()
Copies to the current category the applicable compare products of the parent category, if there are no products to compare for the current category.
(inner) CompareList/findAttributeGroups(classificationCategory) → {dw.util.LinkedHashSet}
Returns the set of attribute groups for the given classification category, each one represented as a map.
Parameters:
Name | Type | Description |
---|---|---|
classificationCategory |
dw.catalog.Category |
The classification category. |
Returns:
Set of maps containing attribute groups. Each map contains:
- descriptor - description of visible attributes in the group.
- displayName - display name of visible attributes in the group.
- attributes - an ArrayList of HashMaps. Each map contains the descriptor and display name for an attribute in the group.
(inner) CompareList/findDeepestCommonCategory(paths)
Returns the deepest common category among the given list of paths starting at the root.
Parameters:
Name | Type | Description |
---|---|---|
paths |
dw.util.ArrayList |
List of paths from root to category. |
(inner) CompareList/fromJSON(json)
Sets the state of this compare list based on the given string, typically from the session. Saves the product comparison to the session.
Parameters:
Name | Type | Description |
---|---|---|
json |
String |
JSON data |
- Source:
- See:
(inner) CompareList/getAttributeGroups() → {dw.util.LinkedHashSet}
Returns a set of maps, each map representing an attribute group.
- Source:
- See:
-
- module:models/CompareModel~CompareList/findAttributeGroups for map structure information.
Returns:
Attribute groups are returned as a set of maps, where each attribute group is a separate map.
(inner) CompareList/getCategories() → {dw.util.LinkedHashMap}
Returns a map of category IDs and names, for all categories that have at least one product to compare.
Returns:
Map of category IDs and display names.
(inner) CompareList/getCategory() → {String}
Returns the current category of products to compare.
Returns:
Current category ID.
- Type
- String
(inner) CompareList/getProducts() → {dw.util.LinkedHashSet}
Returns a set of IDs of products being compared for the current category, or the empty set if no category is selected.
Returns:
Product IDs of any products being compared for the current category.
(inner) CompareList/productAssignedToCategory(p, c) → {Boolean}
Checks if a product is assigned to a category or any child category of the category.
Parameters:
Name | Type | Description |
---|---|---|
p |
dw.catalog.Product |
product |
c |
dw.catalog.Category |
category |
Returns:
true if the product is assigned to the given category or one of its children, or false if it is not.
- Type
- Boolean
(inner) CompareList/remove(p, c)
Removes the given product from the set of compared products for the given category. Saves the current product comparison to the session.
Parameters:
Name | Type | Description |
---|---|---|
p |
dw.catalog.Product |
the product to remove |
c |
dw.catalog.Category |
the category for which to remove the object |
- Source:
- See:
(inner) CompareList/setCategory(categoryID)
Sets the current category of products to compare to the one with the given ID. Saves the current product comparison to the session.
Parameters:
Name | Type | Description |
---|---|---|
categoryID |
String |
The category ID. |
- Source:
- See:
(inner) CompareList/store()
Stores a representation of this product comparison in the session.