@@ -187,28 +187,7 @@ public function getConfiguration()
187
187
188
188
$ attributesToFilter = $ config ->getAttributesToFilter ($ customerGroupId );
189
189
$ algoliaJsConfig = [
190
- 'instant ' => [
191
- 'enabled ' => $ config ->isInstantEnabled (),
192
- 'selector ' => $ config ->getInstantSelector (),
193
- 'isAddToCartEnabled ' => $ config ->isAddToCartEnable (),
194
- 'addToCartParams ' => $ addToCartParams ,
195
- 'infiniteScrollEnabled ' => $ config ->isInfiniteScrollEnabled (),
196
- 'urlTrackedParameters ' => $ this ->getUrlTrackedParameters (),
197
- 'isSearchBoxEnabled ' => $ config ->isInstantSearchBoxEnabled (),
198
- 'isVisualMerchEnabled ' => $ config ->isVisualMerchEnabled (),
199
- 'categorySeparator ' => $ config ->getCategorySeparator (),
200
- 'categoryPageIdAttribute ' => $ config ->getCategoryPageIdAttributeName (),
201
- 'isCategoryNavigationEnabled ' => self ::IS_CATEGORY_NAVIGATION_ENABLED ,
202
- 'hidePagination ' => $ config ->hidePaginationInInstantSearchPage (),
203
- 'isDynamicFacetsEnabled ' => $ config ->isDynamicFacetsEnabled (),
204
- 'redirects ' => [
205
- 'enabled ' => $ this ->instantSearchConfig ->isInstantRedirectEnabled (),
206
- 'onPageLoad ' => in_array (InstantSearchRedirectOptions::REDIRECT_ON_PAGE_LOAD , $ this ->instantSearchConfig ->getInstantRedirectOptions ()),
207
- 'onSearchAsYouType ' => in_array (InstantSearchRedirectOptions::REDIRECT_ON_SEARCH_AS_YOU_TYPE , $ this ->instantSearchConfig ->getInstantRedirectOptions ()),
208
- 'showSelectableRedirect ' => in_array (InstantSearchRedirectOptions::SELECTABLE_REDIRECT , $ this ->instantSearchConfig ->getInstantRedirectOptions ()),
209
- 'openInNewWindow ' => in_array (InstantSearchRedirectOptions::OPEN_IN_NEW_WINDOW , $ this ->instantSearchConfig ->getInstantRedirectOptions ())
210
- ]
211
- ],
190
+ 'instant ' => $ this ->getInstantSearchConfig ($ addToCartParams ),
212
191
'autocomplete ' => $ this ->getAutocompleteConfiguration (),
213
192
'landingPage ' => [
214
193
'query ' => $ this ->getLandingPageQuery (),
@@ -406,6 +385,36 @@ protected function getAutocompleteConfiguration(): array
406
385
];
407
386
}
408
387
388
+ protected function getInstantSearchConfig (array $ addToCartParams ): array
389
+ {
390
+ $ config = $ this ->instantSearchConfig ;
391
+ $ redirectOptions = $ config ->getInstantRedirectOptions ();
392
+ $ mainConfig = $ this ->config ;
393
+
394
+ return [
395
+ 'enabled ' => $ config ->isEnabled (),
396
+ 'selector ' => $ config ->getDomSelector (),
397
+ 'isAddToCartEnabled ' => $ config ->isAddToCartEnabled (),
398
+ 'addToCartParams ' => $ addToCartParams ,
399
+ 'infiniteScrollEnabled ' => $ config ->isInfiniteScrollEnabled (),
400
+ 'urlTrackedParameters ' => $ this ->getUrlTrackedParameters (),
401
+ 'isSearchBoxEnabled ' => $ config ->isSearchBoxEnabled (),
402
+ 'isVisualMerchEnabled ' => $ mainConfig ->isVisualMerchEnabled (),
403
+ 'categorySeparator ' => $ mainConfig ->getCategorySeparator (),
404
+ 'categoryPageIdAttribute ' => $ mainConfig ->getCategoryPageIdAttributeName (),
405
+ 'isCategoryNavigationEnabled ' => self ::IS_CATEGORY_NAVIGATION_ENABLED ,
406
+ 'hidePagination ' => $ config ->shouldHidePagination (),
407
+ 'isDynamicFacetsEnabled ' => $ config ->isDynamicFacetsEnabled (),
408
+ 'redirects ' => [
409
+ 'enabled ' => $ config ->isInstantRedirectEnabled (),
410
+ 'onPageLoad ' => in_array (InstantSearchRedirectOptions::REDIRECT_ON_PAGE_LOAD , $ redirectOptions ),
411
+ 'onSearchAsYouType ' => in_array (InstantSearchRedirectOptions::REDIRECT_ON_SEARCH_AS_YOU_TYPE , $ redirectOptions ),
412
+ 'showSelectableRedirect ' => in_array (InstantSearchRedirectOptions::SELECTABLE_REDIRECT , $ redirectOptions ),
413
+ 'openInNewWindow ' => in_array (InstantSearchRedirectOptions::OPEN_IN_NEW_WINDOW , $ redirectOptions )
414
+ ]
415
+ ];
416
+ }
417
+
409
418
protected function areCategoriesInFacets ($ facets )
410
419
{
411
420
return in_array ('categories ' , array_column ($ facets , 'attribute ' ));
0 commit comments