-
Notifications
You must be signed in to change notification settings - Fork 171
MAGE-1328: Add Algolia Query Suggestions backend configuration #1863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
damcou
merged 7 commits into
release/3.18.0-dev
from
feat/MAGE-1328-algolia-query-suggestions
Nov 12, 2025
+215
−1
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d0e25ed
MAGE-1328: add new configurations
damcou a1d293d
MAGE-1328: add configuration to frontend block and add defaults
damcou 9ab19a1
MAGE-1328: add data patch to activate Magento Suggestions in case it …
damcou fa35c47
MAGE-1328: add condition for the suggestion indexing to depend on the…
damcou f545616
MAGE-1328: add documentation link to the configuration
damcou 6b36823
MAGE-1328: remove indexing control
damcou 5b67ca1
Update Setup/Patch/Data/MigrateSuggestionsConfigPatch.php
damcou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <?php | ||
|
|
||
| namespace Algolia\AlgoliaSearch\Model\Source; | ||
|
|
||
| use Magento\Framework\Data\OptionSourceInterface; | ||
|
|
||
| class Suggestions implements OptionSourceInterface | ||
| { | ||
|
|
||
| public const SUGGESTIONS_DISABLED = 0; | ||
| public const SUGGESTIONS_MAGENTO = 1; | ||
| public const SUGGESTIONS_ALGOLIA = 2; | ||
|
|
||
| public function toOptionArray() | ||
| { | ||
| return [ | ||
| [ | ||
| 'value' => self::SUGGESTIONS_DISABLED, | ||
| 'label' => __('No'), | ||
| ], | ||
| [ | ||
| 'value' => self::SUGGESTIONS_MAGENTO, | ||
| 'label' => __('Use Magento Search Queries (deprecated)'), | ||
| ], | ||
| [ | ||
| 'value' => self::SUGGESTIONS_ALGOLIA, | ||
| 'label' => __('Use Algolia Query Suggestions'), | ||
| ], | ||
| ]; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| <?php | ||
|
|
||
| namespace Algolia\AlgoliaSearch\Setup\Patch\Data; | ||
|
|
||
| use Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper; | ||
| use Algolia\AlgoliaSearch\Model\Source\Suggestions; | ||
| use Magento\Framework\Setup\ModuleDataSetupInterface; | ||
| use Magento\Framework\Setup\Patch\DataPatchInterface; | ||
| use Magento\Framework\Setup\Patch\PatchInterface; | ||
|
|
||
| class MigrateSuggestionsConfigPatch implements DataPatchInterface | ||
| { | ||
| public function __construct( | ||
| protected ModuleDataSetupInterface $moduleDataSetup, | ||
| ) {} | ||
|
|
||
| /** | ||
| * @inheritDoc | ||
| */ | ||
| public function apply(): PatchInterface | ||
| { | ||
| $this->moduleDataSetup->getConnection()->startSetup(); | ||
|
|
||
| $this->moveIndexingSettings(); | ||
|
|
||
| $this->moduleDataSetup->getConnection()->endSetup(); | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * Migrate legacy configurations | ||
| * @return void | ||
| */ | ||
| protected function moveIndexingSettings(): void | ||
| { | ||
| $connection = $this->moduleDataSetup->getConnection(); | ||
| $configDataTable = $this->moduleDataSetup->getTable('core_config_data'); | ||
|
|
||
| // Get current number of configured Magento suggestions | ||
| $whereConfigPathFrom = $connection->quoteInto('path = ?', AutocompleteHelper::NB_OF_QUERIES_SUGGESTIONS); | ||
| $select = $connection->select() | ||
| ->from($configDataTable) | ||
| ->where($whereConfigPathFrom); | ||
damcou marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| $existingValues = $connection->fetchAll($select); | ||
|
|
||
| foreach ($existingValues as $item) { | ||
| // If number of suggestions used to be superior to zero, this means that the feature was activated | ||
| // So we automatically set the suggestion mode to "Magento" | ||
| if ((int) $item['value'] > 0) { | ||
| $connection->insertOnDuplicate( | ||
| $configDataTable, | ||
| [ | ||
| 'scope' => $item['scope'], | ||
| 'scope_id' => $item['scope_id'], | ||
| 'path' => AutocompleteHelper::SUGGESTIONS_MODE, | ||
| 'value' => Suggestions::SUGGESTIONS_MAGENTO | ||
| ] | ||
| ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @inheritDoc | ||
| */ | ||
| public static function getDependencies(): array | ||
| { | ||
| return []; | ||
| } | ||
|
|
||
| /** | ||
| * @inheritDoc | ||
| */ | ||
| public function getAliases(): array | ||
| { | ||
| return []; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.