Skip to content

Commit abab74d

Browse files
committed
MAGE-985 Add POC custom redirect widget
1 parent 157535a commit abab74d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

view/frontend/web/js/instantsearch.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,19 @@ define([
177177

178178
allWidgetConfiguration = this.configureFacets(allWidgetConfiguration);
179179

180+
// allWidgetConfiguration = this.configureRedirects(allWidgetConfiguration)
181+
180182
if (algoliaConfig.analytics.enabled) {
181183
allWidgetConfiguration.analytics = this.getAnalyticsWidget()
182184
}
183185

184186
return allWidgetConfiguration;
185187
},
186188

189+
// configureRedirects(allWidgetConfiguration) {
190+
// return allWidgetConfiguration;
191+
// },
192+
187193
/**
188194
* Process a passed widget config object and add to InstantSearch
189195
* Dynamic widgets are deferred as they must be aggregated and processed separately
@@ -966,6 +972,11 @@ define([
966972
if (algoliaConfig.showSuggestionsOnNoResultsPage) {
967973
customWidgets.push(this.getSuggestionsWidget(this.minQuerySuggestions));
968974
}
975+
976+
const allowRedirects = true;
977+
if (allowRedirects) {
978+
customWidgets.push(this.getRedirectWidget());
979+
}
969980
return customWidgets;
970981
},
971982

@@ -1052,6 +1063,20 @@ define([
10521063
};
10531064
},
10541065

1066+
getRedirectWidget() {
1067+
return {
1068+
render({ results }) {
1069+
if (
1070+
results &&
1071+
results.renderingContent &&
1072+
results.renderingContent.redirect
1073+
) {
1074+
window.location.href = results.renderingContent.redirect.url;
1075+
}
1076+
},
1077+
};
1078+
},
1079+
10551080
////////////////////////////
10561081
// Merchandising //
10571082
////////////////////////////

0 commit comments

Comments
 (0)