Skip to content

Commit 9ba7d13

Browse files
committed
MAGE-938 Expose index settings method in ProductHelper for reuse
1 parent d6b53a4 commit 9ba7d13

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

Helper/Entity/ProductHelper.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,12 @@ public function getAdditionalAttributes(?int $storeId = null): array
297297
}
298298

299299
/**
300-
* @param string $indexName
301-
* @param string $indexNameTmp
302-
* @param int $storeId
303-
* @param bool $saveToTmpIndicesToo
304-
* @return void
305-
* @throws AlgoliaException
300+
* @param int|null $storeId
301+
* @return array<string, mixed>
306302
* @throws LocalizedException
307303
* @throws NoSuchEntityException
308304
*/
309-
public function setSettings(string $indexName, string $indexNameTmp, int $storeId, bool $saveToTmpIndicesToo = false): void
305+
public function getIndexSettings(?int $storeId = null): array
310306
{
311307
$searchableAttributes = $this->getSearchableAttributes($storeId);
312308
$customRanking = $this->getCustomRanking($storeId);
@@ -339,6 +335,23 @@ public function setSettings(string $indexName, string $indexNameTmp, int $storeI
339335

340336
$indexSettings = $transport->getData();
341337

338+
return $indexSettings;
339+
}
340+
341+
/**
342+
* @param string $indexName
343+
* @param string $indexNameTmp
344+
* @param int $storeId
345+
* @param bool $saveToTmpIndicesToo
346+
* @return void
347+
* @throws AlgoliaException
348+
* @throws LocalizedException
349+
* @throws NoSuchEntityException
350+
*/
351+
public function setSettings(string $indexName, string $indexNameTmp, int $storeId, bool $saveToTmpIndicesToo = false): void
352+
{
353+
$indexSettings = $this->getIndexSettings($storeId);
354+
342355
$this->algoliaHelper->setSettings($indexName, $indexSettings, false, true);
343356
$this->logger->log('Settings: ' . json_encode($indexSettings));
344357
if ($saveToTmpIndicesToo) {

0 commit comments

Comments
 (0)