1. @sitecore-cloudsdk/search/server

RecommendationWidgetItem

Version:

Type

Class

Extends

ResultsWidgetItem

Import path

@sitecore-cloudsdk/search/server

A widget item for a recommendation widget.

Constructor

RecommendationWidgetItem(
  entity: string,
  widgetId: string,
  recommendationOptions?: RecommendationOptions,
  sources?: ArrayOfAtLeastOne<string>
)

Parameters

Name

Type

Description

entity

string

Required.

The entity associated with the widget.

widgetId

string

Required.

The unique identifier of the widget.

To find the widget ID in Sitecore Search, click Widgets. Widget IDs are in the RFK ID column.

Example: "rfkid_7"

recommendations

RecommendationOptions

Optional.

Options to determine which recommendations are given by a recommendation widget.

sources

string[]

Optional.

A list of source IDs that identify the sources to include results from. Useful for filtering results by source, for example, when managing multiple sites.

To find source IDs in Sitecore Search, on the menu bar, click Sources.

If set, the response will contain results only from the specified sources.

If unset, the response will return results from all sources.

Example: ["1062132", "1081839"]

Minimum length: 1.

Properties

Name

Type

Description

_recommendation

Recommendation

Optional.

The recommendation object of a widget item.

Accessors

The following properties are available to get and set:

get recipe

get recipe(): Recipe | undefined

Returns the recipe property of the RecommendationWidgetItem instance.

set recipe

set recipe(recipe: Recipe)

Sets the recipe of the RecommendationWidgetItem instance.

Parameters

Name

Type

Description

recipe

Recipe

A recipe for recommendations. A recipe is used to determine which recommendations are given by a recommendation widget.

Methods

_validateRecipe

Validates that the recipe ID is a non-empty string, and that the recipe version is an integer greater than or equal to 1.

Signature

private _validateRecipe(recipe?: Recipe): void

Parameters

Name

Type

Description

recipe

Recipe

A recipe for recommendations. A recipe is used to determine which recommendations are given by a recommendation widget.

Return value

Returns void.

Errors

resetRecipe

Resets recipe to undefined.

Signature

resetRecipe(): void

Return value

Returns void.

resetRecommendations

Resets recommendation to an empty object.

Signature

resetRecommendations(): void

Return value

Returns void.

toDTO

Maps the RecommendationWidgetItem instance to its DTO (data transfer object) format.

Signature

toDTO(): WidgetItemRecommendationDTO

Return value

Returns the RecommendationWidgetItem instance in a standardized DTO format.

If you have suggestions for improving this article, let us know!