Class ProductSearchHit

ProductSearchHit is the result of a executed search query and wraps the actual product found by the search.

The method getRepresentedProducts() returns the actual products that is conforming the query and is represented by the search hit. Depending on the hit typ, getRepresentedProducts() returns:

The ProductSearchHit type can be retrieved by method getHitType() and contains the following types:

The method getProduct() returns the presentation product corresponding to the ProductSearchHit type.

Example:

Given a product master P1 called "Sweater" with attributes color and size that has the following variants:

  • V1 - color: red, size: small
  • V2 - color: red, size: large
  • V3 - color: blue, size: small
  • V4 - color: blue, size: large
  • V5 - color: yellow, size: small
  • V6 - color: yellow, size: large

A search for "red sweater" should hit the first two variants, V1 and V2 that are both red. The ProductSearchHit for this result encompass the master and the red variants but not the other non-relevant variants.

The variants hit by the query can be retrieved by getRepresentedProducts(), returning a list that contains the two red sweater variants.

The master product "Sweater" is returned by getProduct().

Furthermore, to get the first or last of that list of variants hit by the query we can call getFirstRepresentedProduct() or getLastRepresentedProduct(). The product with the highest sort rank is returned first, and the product with the lowest sort rank is returned last. The product sort rank depends on the sorting conditions used for the search query.

ConstantDescription
HIT_TYPE_PRODUCT_BUNDLE: String = "bundle"Constant representing a product search hit type based on the presentation product of a hit.
HIT_TYPE_PRODUCT_MASTER: String = "master"Constant representing a product search hit type based on the presentation product of a hit.
HIT_TYPE_PRODUCT_SET: String = "set"Constant representing a product search hit type based on the presentation product of a hit.
HIT_TYPE_SIMPLE: String = "product"Constant representing a product search hit type based on the presentation product of a hit.
HIT_TYPE_SLICING_GROUP: String = "slicing_group"Constant representing a product search hit type based on the presentation product of a hit.
HIT_TYPE_VARIATION_GROUP: String = "variation_group"Constant representing a product search hit type based on the presentation product of a hit.
PropertyDescription
firstRepresentedProduct: Product (read-only)Returns the product that is actually hit by the search and has the highest sort rank according to the sorting conditions used for the search query.
firstRepresentedProductID: String (read-only)Returns the ID of the product that is actually hit by the search and has the highest sort rank according to the sorting conditions used for the search query.
hitType: String (read-only)Returns the type of the product wrapped by this search hit.
lastRepresentedProduct: Product (read-only)Returns the product that is actually hit by the search and has the lowest sort rank according to the sorting conditions used for the search query.
lastRepresentedProductID: String (read-only)Returns the ID of the product that is actually hit by the search and has the lowest sort rank according to the sorting conditions used for the search query.
maxPrice: Money (read-only)Returns the maximum price of all products represented by the product hit.
maxPricePerUnit: Money (read-only)Returns the maximum price per unit of all products represented by the product hit.
minPrice: Money (read-only)Returns the minimum price of all products represented by the product hit.
minPricePerUnit: Money (read-only)Returns the minimum price per unit of all products represented by the product hit.
priceRange: Boolean (read-only)Convenience method to check whether this ProductSearchHit represents multiple products (see getRepresentedProducts()) that have different prices.
product: Product (read-only)Returns the presentation product of this ProductSearchHit corresponding to the ProductSearchHit type.
productID: String (read-only)Returns the ID of the presentation product of this ProductSearchHit corresponding to the ProductSearchHit type.
representedProductIDs: List (read-only)The method returns the actual ID of the product that is conforming the query and is represented by the search hit.
representedProducts: List (read-only)The method returns the actual product that is conforming the query and is represented by the search hit.

This class does not have a constructor, so you cannot create it directly.

MethodDescription
getFirstRepresentedProduct()Returns the product that is actually hit by the search and has the highest sort rank according to the sorting conditions used for the search query.
getFirstRepresentedProductID()Returns the ID of the product that is actually hit by the search and has the highest sort rank according to the sorting conditions used for the search query.
getHitType()Returns the type of the product wrapped by this search hit.
getLastRepresentedProduct()Returns the product that is actually hit by the search and has the lowest sort rank according to the sorting conditions used for the search query.
getLastRepresentedProductID()Returns the ID of the product that is actually hit by the search and has the lowest sort rank according to the sorting conditions used for the search query.
getMaxPrice()Returns the maximum price of all products represented by the product hit.
getMaxPricePerUnit()Returns the maximum price per unit of all products represented by the product hit.
getMinPrice()Returns the minimum price of all products represented by the product hit.
getMinPricePerUnit()Returns the minimum price per unit of all products represented by the product hit.
getProduct()Returns the presentation product of this ProductSearchHit corresponding to the ProductSearchHit type.
getProductID()Returns the ID of the presentation product of this ProductSearchHit corresponding to the ProductSearchHit type.
getRepresentedProductIDs()The method returns the actual ID of the product that is conforming the query and is represented by the search hit.
getRepresentedProducts()The method returns the actual product that is conforming the query and is represented by the search hit.
getRepresentedVariationValues(Object)This method is only applicable if this ProductSearchHit represents a product variation (see getRepresentedProducts()).
isPriceRange()Convenience method to check whether this ProductSearchHit represents multiple products (see getRepresentedProducts()) that have different prices.

assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values

HIT_TYPE_PRODUCT_BUNDLE: String = "bundle"

Constant representing a product search hit type based on the presentation product of a hit. This hit type is used with product bundles.


HIT_TYPE_PRODUCT_MASTER: String = "master"

Constant representing a product search hit type based on the presentation product of a hit. This hit type is used with master products.


HIT_TYPE_PRODUCT_SET: String = "set"

Constant representing a product search hit type based on the presentation product of a hit. This hit type is used with product sets.


HIT_TYPE_SIMPLE: String = "product"

Constant representing a product search hit type based on the presentation product of a hit. This hit type is used with single, non-complex products, including product variants that are assigned to a category and are returned as the presentation product.


HIT_TYPE_SLICING_GROUP: String = "slicing_group"

Constant representing a product search hit type based on the presentation product of a hit. This hit type is used with slicing groups.

Deprecated:

Please use HIT_TYPE_VARIATION_GROUP instead.


HIT_TYPE_VARIATION_GROUP: String = "variation_group"

Constant representing a product search hit type based on the presentation product of a hit. This hit type is used with variation groups.


firstRepresentedProduct: Product (read-only)

Returns the product that is actually hit by the search and has the highest sort rank according to the sorting conditions used for the search query.

See Also:


firstRepresentedProductID: String (read-only)

Returns the ID of the product that is actually hit by the search and has the highest sort rank according to the sorting conditions used for the search query.

See Also:


hitType: String (read-only)

Returns the type of the product wrapped by this search hit. The product type returned will be one of the hit types:


lastRepresentedProduct: Product (read-only)

Returns the product that is actually hit by the search and has the lowest sort rank according to the sorting conditions used for the search query.

See Also:


lastRepresentedProductID: String (read-only)

Returns the ID of the product that is actually hit by the search and has the lowest sort rank according to the sorting conditions used for the search query.

See Also:


maxPrice: Money (read-only)

Returns the maximum price of all products represented by the product hit. See getRepresentedProducts() for details on the set of products used for finding the maximum. The method returns N/A in case no price information can be found.

Note: The method uses price information of the search index and therefore might return different prices than the ProductPriceModel.


maxPricePerUnit: Money (read-only)

Returns the maximum price per unit of all products represented by the product hit. See getRepresentedProducts() for details on the set of products used for finding the maximum. The method returns N/A in case no price information can be found.

Note: The method uses price information of the search index and therefore might return different prices than the ProductPriceModel.


minPrice: Money (read-only)

Returns the minimum price of all products represented by the product hit. See getRepresentedProducts() for details on the set of products used for finding the minimum. The method returns N/A in case no price information can be found.

Note: the method uses price information of the search index and therefore might return different prices than the ProductPriceModel.


minPricePerUnit: Money (read-only)

Returns the minimum price per unit of all products represented by the product hit. See getRepresentedProducts() for details on the set of products used for finding the minimum. The method returns N/A in case no price information can be found.

Note: the method uses price information of the search index and therefore might return different prices than the ProductPriceModel.


priceRange: Boolean (read-only)

Convenience method to check whether this ProductSearchHit represents multiple products (see getRepresentedProducts()) that have different prices.


product: Product (read-only)

Returns the presentation product of this ProductSearchHit corresponding to the ProductSearchHit type.

To retrieve the product(s) actually hit by the search use getRepresentedProducts().

See Also:


productID: String (read-only)

Returns the ID of the presentation product of this ProductSearchHit corresponding to the ProductSearchHit type.

To retrieve the ID of the product actually hit by the search use getFirstRepresentedProductID() or getLastRepresentedProductID().

See Also:


representedProductIDs: List (read-only)

The method returns the actual ID of the product that is conforming the query and is represented by the search hit. Depending on the hit typ, it returns the ID of:

If the method returns multiple products, the product with the highest sort rank is returned first, and the product with the lowest sort rank is returned last. The product sort rank depends on the sorting conditions used for the search query.

See Also:


representedProducts: List (read-only)

The method returns the actual product that is conforming the query and is represented by the search hit. Depending on the hit typ, getRepresentedProducts() returns:

If the method returns multiple products, the product with the highest sort rank is returned first, and the product with the lowest sort rank is returned last. The product sort rank depends on the sorting conditions used for the search query.

See Also:


getFirstRepresentedProduct(): Product

Returns the product that is actually hit by the search and has the highest sort rank according to the sorting conditions used for the search query.

Returns:

  • the first product that is actually hit by the search

See Also:


getFirstRepresentedProductID(): String

Returns the ID of the product that is actually hit by the search and has the highest sort rank according to the sorting conditions used for the search query.

Returns:

  • the ID of the first product that is actually hit by the search

See Also:


getHitType(): String

Returns the type of the product wrapped by this search hit. The product type returned will be one of the hit types:

Returns:

  • search hit type

getLastRepresentedProduct(): Product

Returns the product that is actually hit by the search and has the lowest sort rank according to the sorting conditions used for the search query.

Returns:

  • the last product that is actually hit by the search

See Also:


getLastRepresentedProductID(): String

Returns the ID of the product that is actually hit by the search and has the lowest sort rank according to the sorting conditions used for the search query.

Returns:

  • the ID of the last product that is actually hit by the search

See Also:


getMaxPrice(): Money

Returns the maximum price of all products represented by the product hit. See getRepresentedProducts() for details on the set of products used for finding the maximum. The method returns N/A in case no price information can be found.

Note: The method uses price information of the search index and therefore might return different prices than the ProductPriceModel.

Returns:

  • the maximum price of all products represented by the product hit.

getMaxPricePerUnit(): Money

Returns the maximum price per unit of all products represented by the product hit. See getRepresentedProducts() for details on the set of products used for finding the maximum. The method returns N/A in case no price information can be found.

Note: The method uses price information of the search index and therefore might return different prices than the ProductPriceModel.

Returns:

  • the maximum price per unit of all products represented by the product hit.

getMinPrice(): Money

Returns the minimum price of all products represented by the product hit. See getRepresentedProducts() for details on the set of products used for finding the minimum. The method returns N/A in case no price information can be found.

Note: the method uses price information of the search index and therefore might return different prices than the ProductPriceModel.

Returns:

  • the minimum price of all products represented by the product hit.

getMinPricePerUnit(): Money

Returns the minimum price per unit of all products represented by the product hit. See getRepresentedProducts() for details on the set of products used for finding the minimum. The method returns N/A in case no price information can be found.

Note: the method uses price information of the search index and therefore might return different prices than the ProductPriceModel.

Returns:

  • the minimum price per unit of all products represented by the product hit.

getProduct(): Product

Returns the presentation product of this ProductSearchHit corresponding to the ProductSearchHit type.

To retrieve the product(s) actually hit by the search use getRepresentedProducts().

Returns:

  • the presentation product of this ProductSearchHit, which is possibly a representative of other related products actually hit by the search.

See Also:


getProductID(): String

Returns the ID of the presentation product of this ProductSearchHit corresponding to the ProductSearchHit type.

To retrieve the ID of the product actually hit by the search use getFirstRepresentedProductID() or getLastRepresentedProductID().

Returns:

  • the ID of the presentation product of this ProductSearchHit, that possibly represents a set of related products actually hit by the search.

See Also:


getRepresentedProductIDs(): List

The method returns the actual ID of the product that is conforming the query and is represented by the search hit. Depending on the hit typ, it returns the ID of:

If the method returns multiple products, the product with the highest sort rank is returned first, and the product with the lowest sort rank is returned last. The product sort rank depends on the sorting conditions used for the search query.

Returns:

  • a sorted list of products represented by the wrapped product.

See Also:


getRepresentedProducts(): List

The method returns the actual product that is conforming the query and is represented by the search hit. Depending on the hit typ, getRepresentedProducts() returns:

If the method returns multiple products, the product with the highest sort rank is returned first, and the product with the lowest sort rank is returned last. The product sort rank depends on the sorting conditions used for the search query.

Returns:

  • a sorted list of products represented by the wrapped product.

See Also:


getRepresentedVariationValues(va: Object): List

This method is only applicable if this ProductSearchHit represents a product variation (see getRepresentedProducts()). It returns the distinct value set for the specified variation attribute for all variants represented by this ProductSearchHit. The values are returned in the same order as they are defined for the variation.

This method will accept a ProductVariationAttribute parameter or a String which is the ID of a variation attribute. If any other object type is passed, or null is passed, an exception will be thrown. If this ProductSearchHit does not represent a product variation, or the passed variation attribute is not associated with this product, the method returns an empty list.

Parameters:

  • va - the product variation attribute, specified as either a ProductVariationAttribute or a String which is the ID of a variation attribute associated with this product.

Returns:

  • a list containing all distinct ProductVariationAttributeValues.

isPriceRange(): Boolean

Convenience method to check whether this ProductSearchHit represents multiple products (see getRepresentedProducts()) that have different prices.

Returns:

  • true if the represented products form a price range false otherwise.