Skip to content

Commit 08fc100

Browse files
committed
MAGE-986 Refactor config to utilize Autocomplete helper
1 parent 380824a commit 08fc100

File tree

4 files changed

+435
-214
lines changed

4 files changed

+435
-214
lines changed

Block/Adminhtml/System/Config/Form/Field/Checkboxes.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ class Checkboxes extends Field
1010
protected function _getElementHtml(AbstractElement $element)
1111
{
1212
$html = '';
13-
$elementId = $element->getHtmlId();
1413
$name = $element->getName();
1514
$options = $element->getValues();
1615
$values = empty($element->getValue()) ? [] : explode(',', $element->getValue()); // store as CSV in config

Block/Configuration.php

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -209,24 +209,7 @@ public function getConfiguration()
209209
'openInNewWindow' => in_array(InstantSearchRedirectOptions::OPEN_IN_NEW_WINDOW, $this->instantSearchConfig->getInstantRedirectOptions())
210210
]
211211
],
212-
'autocomplete' => [
213-
'enabled' => $config->isAutoCompleteEnabled(),
214-
'selector' => $config->getAutocompleteSelector(),
215-
'sections' => $config->getAutocompleteSections(),
216-
'nbOfProductsSuggestions' => $config->getNumberOfProductsSuggestions(),
217-
'nbOfCategoriesSuggestions' => $config->getNumberOfCategoriesSuggestions(),
218-
'nbOfQueriesSuggestions' => $config->getNumberOfQueriesSuggestions(),
219-
'isDebugEnabled' => $config->isAutocompleteDebugEnabled(),
220-
'isNavigatorEnabled' => $config->isAutocompleteNavigatorEnabled(),
221-
'debounceMilliseconds' => $config->getAutocompleteDebounceMilliseconds(),
222-
'minimumCharacters' => $config->getAutocompleteMinimumCharacterLength(),
223-
'redirects' => [
224-
'enabled' => $this->autocompleteConfig->isAutocompleteRedirectEnabled(),
225-
'showSelectableRedirect' => $this->autocompleteConfig->getAutocompleteRedirectMode() !== AutocompleteRedirectMode::SUBMIT_ONLY,
226-
'showHitsWithRedirect' => $this->autocompleteConfig->getAutocompleteRedirectMode() !== AutocompleteRedirectMode::SELECTABLE_REDIRECT,
227-
'openInNewWindow' => $this->autocompleteConfig->isAutocompleteRedirectInNewWindowEnabled()
228-
]
229-
],
212+
'autocomplete' => $this->getAutocompleteConfiguration(),
230213
'landingPage' => [
231214
'query' => $this->getLandingPageQuery(),
232215
'configuration' => $this->getLandingPageConfiguration(),
@@ -400,6 +383,29 @@ public function getConfiguration()
400383
return $transport->getData();
401384
}
402385

386+
protected function getAutocompleteConfiguration(): array
387+
{
388+
$config = $this->autocompleteConfig;
389+
return [
390+
'enabled' => $config->isEnabled(),
391+
'selector' => $config->getDomSelector(),
392+
'sections' => $config->getAdditionalSections(),
393+
'nbOfProductsSuggestions' => $config->getNumberOfProductsSuggestions(),
394+
'nbOfCategoriesSuggestions' => $config->getNumberOfCategoriesSuggestions(),
395+
'nbOfQueriesSuggestions' => $config->getNumberOfQueriesSuggestions(),
396+
'isDebugEnabled' => $config->isDebugEnabled(),
397+
'isNavigatorEnabled' => $config->isKeyboardNavigationEnabled(),
398+
'debounceMilliseconds' => $config->getDebounceMilliseconds(),
399+
'minimumCharacters' => $config->getMinimumCharacterLength(),
400+
'redirects' => [
401+
'enabled' => $config->isRedirectEnabled(),
402+
'showSelectableRedirect' => $config->getRedirectMode() !== AutocompleteRedirectMode::SUBMIT_ONLY,
403+
'showHitsWithRedirect' => $config->getRedirectMode() !== AutocompleteRedirectMode::SELECTABLE_REDIRECT,
404+
'openInNewWindow' => $config->isRedirectInNewWindowEnabled()
405+
]
406+
];
407+
}
408+
403409
protected function areCategoriesInFacets($facets)
404410
{
405411
return in_array('categories', array_column($facets, 'attribute'));

0 commit comments

Comments
 (0)