1. Classes

RecommendationWidgetItem

Version:
TypeClass
ExtendsResultsWidgetItem
Import path@sitecore-cloudsdk/search/browser

A widget item for a recommendation widget.

Constructor

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

Parameters

NameTypeDescription
entitystringRequired.

The entity associated with the widget.
widgetIdstringRequired.

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"
recommendationsRecommendationOptionsOptional.

Options to determine which recommendations are given by a recommendation widget.
sourcesstring[]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

NameTypeDescription
_recommendationRecommendationOptional.

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

NameTypeDescription
recipeRecipeA 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

NameTypeDescription
recipeRecipeA 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!