Skip to content

Commit da9e086

Browse files
committed
MAGE-1122 Add feature flag via admin config
1 parent 449300c commit da9e086

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

Helper/ConfigHelper.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class ConfigHelper
108108
public const CONNECTION_TIMEOUT = 'algoliasearch_advanced/advanced/connection_timeout';
109109
public const READ_TIMEOUT = 'algoliasearch_advanced/advanced/read_timeout';
110110
public const WRITE_TIMEOUT = 'algoliasearch_advanced/advanced/write_timeout';
111+
public const AUTO_PRICE_INDEXING_ENABLED = 'algoliasearch_advanced/advanced/auto_price_indexing';
111112

112113
public const PROFILER_ENABLED = 'algoliasearch_advanced/advanced/enable_profiler';
113114

@@ -1284,6 +1285,15 @@ public function getWriteTimeout($storeId = null)
12841285
return $this->configInterface->getValue(self::WRITE_TIMEOUT, ScopeInterface::SCOPE_STORE, $storeId);
12851286
}
12861287

1288+
public function isAutoPriceIndexingEnabled(?int $storeId = null): bool
1289+
{
1290+
return $this->configInterface->isSetFlag(
1291+
self::AUTO_PRICE_INDEXING_ENABLED,
1292+
ScopeInterface::SCOPE_STORE,
1293+
$storeId
1294+
);
1295+
}
1296+
12871297
/**
12881298
* @param $storeId
12891299
* @return array|bool|float|int|mixed|string
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Algolia\AlgoliaSearch\Model\Config;
4+
5+
use Magento\Config\Model\Config\CommentInterface;
6+
use Magento\Framework\UrlInterface;
7+
8+
class AutomaticPriceIndexingComment implements CommentInterface
9+
{
10+
public function __construct(
11+
protected UrlInterface $urlInterface
12+
) { }
13+
14+
public function getCommentText($elementValue)
15+
{
16+
$url = $this->urlInterface->getUrl('https://www.algolia.com/doc/integration/magento-2/how-it-works/indexing-queue/#configure-the-queue');
17+
18+
$comment = array();
19+
$comment[] = 'Algolia relies on the core Magento Product Price index when serializing product data. If the price index is not up to date, Algolia will not be able to accurately determine what should be included in the search index.';
20+
$comment[] = 'If you are experiencing problems with products not syncing to Algolia due to this issue, enabling this setting will allow Algolia to automatically update the price index as needed.';
21+
$comment[] = 'NOTE: This can introduce a marginal amount of overhead to the indexing process so only enable if necessary. Be sure to <a href="' . $url . '" target="_blank">optimize the indexing queue</a> based on the impact of this operation.';
22+
return implode('<br><br>', $comment);
23+
}
24+
}

etc/adminhtml/system.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,16 @@
13371337
<field id="write_timeout" translate="label comment" type="text" sortOrder="110" showInDefault="1">
13381338
<label>Write Timeout (In Seconds)</label>
13391339
</field>
1340+
<field id="auto_price_indexing" translate="label comment" type="select" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="1">
1341+
<label>Enable automatic price indexing</label>
1342+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
1343+
<comment>
1344+
<model>Algolia\AlgoliaSearch\Model\Config\AutomaticPriceIndexingComment</model>
1345+
</comment>
1346+
<depends>
1347+
<field id="active">1</field>
1348+
</depends>
1349+
</field>
13401350
<field id="enable_profiler" translate="label comment" type="select" sortOrder="130" showInDefault="1">
13411351
<label>Enable Profiler</label>
13421352
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>

etc/config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
<connection_timeout>2</connection_timeout>
9595
<read_timeout>30</read_timeout>
9696
<write_timeout>30</write_timeout>
97+
<auto_price_indexing>0</auto_price_indexing>
9798
<enable_profiler>0</enable_profiler>
9899
</advanced>
99100
<queue>

0 commit comments

Comments
 (0)