Skip to content

Commit b7c6703

Browse files
committed
MAGE-1270: move indexing configuration to indexing manager section
1 parent 0704c91 commit b7c6703

File tree

10 files changed

+67
-62
lines changed

10 files changed

+67
-62
lines changed

Helper/ConfigHelper.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
class ConfigHelper
2222
{
2323
public const ENABLE_FRONTEND = 'algoliasearch_credentials/credentials/enable_frontend';
24-
public const ENABLE_BACKEND = 'algoliasearch_credentials/credentials/enable_backend';
25-
public const ENABLE_QUERY_SUGGESTIONS_INDEX = 'algoliasearch_credentials/credentials/enable_query_suggestions_index';
26-
public const ENABLE_PAGES_INDEX = 'algoliasearch_credentials/credentials/enable_pages_index';
2724
public const LOGGING_ENABLED = 'algoliasearch_credentials/credentials/debug';
2825
public const APPLICATION_ID = 'algoliasearch_credentials/credentials/application_id';
2926
public const API_KEY = 'algoliasearch_credentials/credentials/api_key';
@@ -133,6 +130,9 @@ class ConfigHelper
133130
public const ARCHIVE_LOG_CLEAR_LIMIT = 'algoliasearch_advanced/queue/archive_clear_limit';
134131

135132
// Indexing Manager settings
133+
public const ENABLE_INDEXING = 'algoliasearch_indexing_manager/algolia_indexing/enable_indexing';
134+
public const ENABLE_QUERY_SUGGESTIONS_INDEX = 'algoliasearch_indexing_manager/algolia_indexing/enable_query_suggestions_index';
135+
public const ENABLE_PAGES_INDEX = 'algoliasearch_indexing_manager/algolia_indexing/credentials/enable_pages_index';
136136
public const ENABLE_INDEXER_PRODUCTS = 'algoliasearch_indexing_manager/full_indexing/products';
137137
public const ENABLE_INDEXER_CATEGORIES = 'algoliasearch_indexing_manager/full_indexing/categories';
138138
public const ENABLE_INDEXER_PAGES = 'algoliasearch_indexing_manager/full_indexing/pages';
@@ -247,9 +247,9 @@ public function isEnabledFrontEnd($storeId = null)
247247
* @param $storeId
248248
* @return bool
249249
*/
250-
public function isEnabledBackend($storeId = null)
250+
public function isIndexingEnabled($storeId = null)
251251
{
252-
return $this->configInterface->isSetFlag(self::ENABLE_BACKEND, ScopeInterface::SCOPE_STORE, $storeId);
252+
return $this->configInterface->isSetFlag(self::ENABLE_INDEXING, ScopeInterface::SCOPE_STORE, $storeId);
253253
}
254254

255255
/**

Helper/Data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function getSearchResult(string $query, int $storeId, ?array $searchParam
189189
*/
190190
public function isIndexingEnabled($storeId = null): bool
191191
{
192-
if ($this->configHelper->isEnabledBackend($storeId) === false) {
192+
if ($this->configHelper->isIndexingEnabled($storeId) === false) {
193193
$this->logger->log('INDEXING IS DISABLED FOR ' . $this->logger->getStoreName($storeId));
194194
return false;
195195
}

Helper/Entity/PageHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function getStores($storeId = null)
105105
if ($storeId === null) {
106106
/** @var \Magento\Store\Model\Store $store */
107107
foreach ($this->storeManager->getStores() as $store) {
108-
if ($this->configHelper->isEnabledBackEnd($store->getId()) === false) {
108+
if ($this->configHelper->isIndexingEnabled($store->getId()) === false) {
109109
continue;
110110
}
111111

Service/AbstractIndexBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct(
3030
*/
3131
protected function isIndexingEnabled($storeId = null): bool
3232
{
33-
if ($this->configHelper->isEnabledBackend($storeId) === false) {
33+
if ($this->configHelper->isIndexingEnabled($storeId) === false) {
3434
$this->logger->log('INDEXING IS DISABLED FOR ' . $this->logger->getStoreName($storeId));
3535
return false;
3636
}

Service/Product/ReplicaManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ function($replica) use ($replicas) {
494494
*/
495495
public function isReplicaSyncEnabled(int $storeId): bool
496496
{
497-
return $this->configHelper->isInstantEnabled($storeId) && $this->configHelper->isEnabledBackend($storeId);
497+
return $this->configHelper->isInstantEnabled($storeId) && $this->configHelper->isIndexingEnabled($storeId);
498498
}
499499

500500
/**

Setup/Patch/Schema/ConfigPatch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ConfigPatch implements SchemaPatchInterface
3030
* @var string[]
3131
*/
3232
protected $defaultConfigData = [
33-
'algoliasearch_credentials/credentials/enable_backend' => '1',
33+
'algoliasearch_indexing_manager/algolia_indexing/enable_indexing' => '1',
3434
'algoliasearch_credentials/credentials/enable_frontend' => '1',
3535
'algoliasearch_credentials/credentials/application_id' => '',
3636
'algoliasearch_credentials/credentials/search_only_api_key' => '',

Test/Integration/Indexing/Product/ReplicaIndexingTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ public function testReplicaSync(): void
192192
}
193193

194194
/**
195-
* @magentoConfigFixture current_store algoliasearch_credentials/credentials/enable_backend 0
196-
* @magentoConfigFixture current_store algoliasearch_instant/instant/is_instant_enabled 1
195+
* @magentoConfigFixture current_store algoliasearch_indexing_manager/algolia_indexing/enable_indexing 0
196+
* @magentoConfigFixture current_store algoliasearch_indexing_manager/algolia_indexing/enable_indexing 1
197197
* @throws AlgoliaException
198198
* @throws ExceededRetriesException
199199
* @throws \ReflectionException
@@ -241,7 +241,7 @@ public function testReplicaDeleteUnreliable(): void
241241

242242
/**
243243
* Test the RebuildReplicasPatch with API failures
244-
* @magentoConfigFixture current_store algoliasearch_credentials/credentials/enable_backend 1
244+
* @magentoConfigFixture current_store algoliasearch_indexing_manager/algolia_indexing/enable_indexing 1
245245
* @magentoConfigFixture current_store algoliasearch_instant/instant/is_instant_enabled 1
246246
*/
247247
public function testReplicaRebuildPatch(): void

Test/Integration/_files/second_website_with_two_stores_and_products.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@
6767

6868
$configManager = $objectManager->get(\Magento\Framework\App\Config\MutableScopeConfigInterface::class);
6969
// Temporarily disable indexing during product assignment to stores
70-
$configManager->setValue('algoliasearch_credentials/credentials/enable_backend', 0, 'store', 'admin');
71-
$configManager->setValue('algoliasearch_credentials/credentials/enable_backend', 0, 'store', 'default');
72-
$configManager->setValue('algoliasearch_credentials/credentials/enable_backend', 0, 'store', 'fixture_second_store');
73-
$configManager->setValue('algoliasearch_credentials/credentials/enable_backend', 0, 'store', 'fixture_third_store');
70+
$configManager->setValue('algoliasearch_indexing_manager/algolia_indexing/enable_indexing', 0, 'store', 'admin');
71+
$configManager->setValue('algoliasearch_indexing_manager/algolia_indexing/enable_indexing', 0, 'store', 'default');
72+
$configManager->setValue('algoliasearch_indexing_manager/algolia_indexing/enable_indexing', 0, 'store', 'fixture_second_store');
73+
$configManager->setValue('algoliasearch_indexing_manager/algolia_indexing/enable_indexing', 0, 'store', 'fixture_third_store');
7474

7575
$productSkus = MultiStoreProductsTest::SKUS;
7676
$productRepository = Bootstrap::getObjectManager()
@@ -82,10 +82,10 @@
8282
$productRepository->save($product);
8383
}
8484

85-
$configManager->setValue('algoliasearch_credentials/credentials/enable_backend', 1, 'store', 'admin');
86-
$configManager->setValue('algoliasearch_credentials/credentials/enable_backend', 1, 'store', 'default');
87-
$configManager->setValue('algoliasearch_credentials/credentials/enable_backend', 1, 'store', 'fixture_second_store');
88-
$configManager->setValue('algoliasearch_credentials/credentials/enable_backend', 1, 'store', 'fixture_third_store');
85+
$configManager->setValue('algoliasearch_indexing_manager/algolia_indexing/enable_indexing', 1, 'store', 'admin');
86+
$configManager->setValue('algoliasearch_indexing_manager/algolia_indexing/enable_indexing', 1, 'store', 'default');
87+
$configManager->setValue('algoliasearch_indexing_manager/algolia_indexing/enable_indexing', 1, 'store', 'fixture_second_store');
88+
$configManager->setValue('algoliasearch_indexing_manager/algolia_indexing/enable_indexing', 1, 'store', 'fixture_third_store');
8989

9090
/* Refresh CatalogSearch index */
9191
/** @var IndexerRegistry $indexerRegistry */

etc/adminhtml/system.xml

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -53,43 +53,6 @@
5353
]]>
5454
</comment>
5555
</field>
56-
<field id="enable_backend" translate="label comment" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
57-
<label>Enable Indexing</label>
58-
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
59-
<comment>
60-
<![CDATA[
61-
Do you want the Algolia extension to push your data to Algolia?<br>
62-
The benefit here is that Algolia will manage to keep your data up to date.
63-
If you choose "No", you will need to push and manage your data in a different way.
64-
]]>
65-
</comment>
66-
</field>
67-
<field id="enable_query_suggestions_index" translate="label comment" type="select" sortOrder="41" showInDefault="1" showInWebsite="1" showInStore="1">
68-
<label>Enable Query Suggestions Index</label>
69-
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
70-
<comment>
71-
<![CDATA[
72-
Do you want the Algolia extension to push your search terms/suggestions to Algolia?<br>
73-
If you choose "No", _suggestion indexes will not be created.
74-
]]>
75-
</comment>
76-
<depends>
77-
<field id="enable_backend">1</field>
78-
</depends>
79-
</field>
80-
<field id="enable_pages_index" translate="label comment" type="select" sortOrder="41" showInDefault="1" showInWebsite="1" showInStore="1">
81-
<label>Enable Pages Index</label>
82-
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
83-
<comment>
84-
<![CDATA[
85-
Do you want the Algolia extension to push your CMS Pages to Algolia?<br>
86-
If you choose "No", _pages indexes will not be created.
87-
]]>
88-
</comment>
89-
<depends>
90-
<field id="enable_backend">1</field>
91-
</depends>
92-
</field>
9356
<field id="enable_frontend" translate="label comment" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
9457
<label>Enable Search</label>
9558
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
@@ -1085,6 +1048,47 @@
10851048
<label>Indexing Manager</label>
10861049
<tab>algolia</tab>
10871050
<resource>Algolia_AlgoliaSearch::algolia_algoliasearch</resource>
1051+
<group id="algolia_indexing" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
1052+
<label>Enable Algolia indexing</label>
1053+
<attribute type="expanded">1</attribute>
1054+
<field id="enable_indexing" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
1055+
<label>Enable Indexing</label>
1056+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
1057+
<comment>
1058+
<![CDATA[
1059+
Do you want the Algolia extension to push your data to Algolia?<br>
1060+
The benefit here is that Algolia will manage to keep your data up to date.
1061+
If you choose "No", you will need to push and manage your data in a different way.
1062+
]]>
1063+
</comment>
1064+
</field>
1065+
<field id="enable_query_suggestions_index" translate="label comment" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
1066+
<label>Enable Query Suggestions Index</label>
1067+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
1068+
<comment>
1069+
<![CDATA[
1070+
Do you want the Algolia extension to push your search terms/suggestions to Algolia?<br>
1071+
If you choose "No", _suggestion indexes will not be created.
1072+
]]>
1073+
</comment>
1074+
<depends>
1075+
<field id="algolia_indexing">1</field>
1076+
</depends>
1077+
</field>
1078+
<field id="enable_pages_index" translate="label comment" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
1079+
<label>Enable Pages Index</label>
1080+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
1081+
<comment>
1082+
<![CDATA[
1083+
Do you want the Algolia extension to push your CMS Pages to Algolia?<br>
1084+
If you choose "No", _pages indexes will not be created.
1085+
]]>
1086+
</comment>
1087+
<depends>
1088+
<field id="algolia_indexing">1</field>
1089+
</depends>
1090+
</field>
1091+
</group>
10881092
<group id="full_indexing" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
10891093
<label>Full indexing via Magento indexers</label>
10901094
<comment>

etc/config.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
99
<default>
1010
<algoliasearch_credentials>
11-
<credentials>
12-
<enable_query_suggestions_index>1</enable_query_suggestions_index>
13-
<enable_pages_index>1</enable_pages_index>
14-
</credentials>
1511
<algolia_cookie_configuration>
1612
<default_consent_cookie_name>user_allowed_save_cookie</default_consent_cookie_name>
1713
<allow_cookie_button_selector>#btn-cookie-allow</allow_cookie_button_selector>
@@ -73,6 +69,11 @@
7369
</queue>
7470
</algoliasearch_queue>
7571
<algoliasearch_indexing_manager>
72+
<algolia_indexing>
73+
<enable_indexing>1</enable_indexing>
74+
<enable_query_suggestions_index>1</enable_query_suggestions_index>
75+
<enable_pages_index>1</enable_pages_index>
76+
</algolia_indexing>
7677
<full_indexing>
7778
<products>0</products>
7879
<categories>0</categories>

0 commit comments

Comments
 (0)