Skip to content

Commit 28c12b5

Browse files
committed
MAGE-1281 Support replica forwarding across entities
1 parent 92f95f0 commit 28c12b5

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- The indexing queue cron job can now be configured from the Magento admin.
1313
- Dynamic faceting through Algolia merchandising rules is now supported in Magento via an opt-in feature flag.
1414
- No code redirects via merchandising rules in Algolia are now supported in Magento for both Autocomplete and InstantSearch. Support is enabled by default for Autocomplete.
15+
- Settings updates are now automatically forwarded to replicas (if this behavior is not desirable it can be disabled in the admin)
1516
- Integration tests and unit tests added
1617

1718
### Bug Fixes

Model/IndicesConfigurator.php

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Algolia\AlgoliaSearch\Service\Category\IndexOptionsBuilder as CategoryIndexOptionsBuilder;
1818
use Algolia\AlgoliaSearch\Service\Page\IndexOptionsBuilder as PageIndexOptionsBuilder;
1919
use Algolia\AlgoliaSearch\Service\Product\IndexOptionsBuilder as ProductIndexOptionsBuilder;
20+
use Algolia\AlgoliaSearch\Service\ReplicaSettingsHandler;
2021
use Algolia\AlgoliaSearch\Service\Suggestion\IndexOptionsBuilder as SuggestionIndexOptionsBuilder;
2122
use Magento\Framework\Exception\NoSuchEntityException;
2223

@@ -37,6 +38,7 @@ public function __construct(
3738
protected SuggestionHelper $suggestionHelper,
3839
protected AdditionalSectionHelper $additionalSectionHelper,
3940
protected AlgoliaCredentialsManager $algoliaCredentialsManager,
41+
protected ReplicaSettingsHandler $replicaSettingsHandler,
4042
protected DiagnosticsLogger $logger
4143
) {}
4244

@@ -108,12 +110,7 @@ protected function setCategoriesSettings(int $storeId): void
108110
$settings = $this->categoryHelper->getIndexSettings($storeId);
109111
$indexOptions = $this->categoryIndexOptionsBuilder->buildEntityIndexOptions($storeId);
110112

111-
$this->algoliaConnector->setSettings(
112-
$indexOptions,
113-
$settings,
114-
false,
115-
true
116-
);
113+
$this->replicaSettingsHandler->setSettings($indexOptions, $settings);
117114

118115
$this->logger->log('Index name: ' . $indexOptions->getIndexName());
119116
$this->logger->log('Settings: ' . json_encode($settings));
@@ -133,12 +130,7 @@ protected function setPagesSettings(int $storeId): void
133130
$settings = $this->pageHelper->getIndexSettings($storeId);
134131
$indexOptions = $this->pageIndexOptionsBuilder->buildEntityIndexOptions($storeId);
135132

136-
$this->algoliaConnector->setSettings(
137-
$indexOptions,
138-
$settings,
139-
false,
140-
true
141-
);
133+
$this->replicaSettingsHandler->setSettings($indexOptions, $settings);
142134

143135
$this->logger->log('Index name: ' . $indexOptions->getIndexName());
144136
$this->logger->log('Settings: ' . json_encode($settings));
@@ -158,12 +150,7 @@ protected function setQuerySuggestionsSettings(int $storeId): void
158150
$settings = $this->suggestionHelper->getIndexSettings($storeId);
159151
$indexOptions = $this->suggestionIndexOptionsBuilder->buildEntityIndexOptions($storeId);
160152

161-
$this->algoliaConnector->setSettings(
162-
$indexOptions,
163-
$settings,
164-
false,
165-
true
166-
);
153+
$this->replicaSettingsHandler->setSettings($indexOptions, $settings);
167154

168155
$this->logger->log('Index name: ' . $indexOptions->getIndexName());
169156
$this->logger->log('Settings: ' . json_encode($settings));
@@ -192,7 +179,7 @@ protected function setAdditionalSectionsSettings(int $storeId): void
192179
$settings = $this->additionalSectionHelper->getIndexSettings($storeId);
193180
$indexOptions = $this->indexOptionsBuilder->buildWithEnforcedIndex($indexName, $storeId);
194181

195-
$this->algoliaConnector->setSettings($indexOptions, $settings);
182+
$this->replicaSettingsHandler->setSettings($indexOptions, $settings);
196183

197184
$this->logger->log('Index name: ' . $indexName);
198185
$this->logger->log('Settings: ' . json_encode($settings));

0 commit comments

Comments
 (0)