menu

SiteGenesis / Server-side JS / Module: models/CompareModel

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.

Source:

Classes

CompareList

Methods

(static) get() → {models/CompareModel~CompareList}

Returns the product compare list, possibly restored using JSON data from the session.

Source:
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.

Source:

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

Source:
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.
Type
dw.util.LinkedHashSet

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

Source:

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

Type
dw.util.LinkedHashSet

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

Source:
Returns:

Map of category IDs and display names.

Type
dw.util.LinkedHashMap

(inner) CompareList/getCategory() → {String}

Returns the current category of products to compare.

Source:
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.

Source:
Returns:

Product IDs of any products being compared for the current category.

Type
dw.util.LinkedHashSet

(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

Source:
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.

Source:

X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.