Skip to content

Commit 91b3f88

Browse files
committed
MAGE-838 Add distinct method for replica sync enablement
1 parent 439fa40 commit 91b3f88

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Api/Product/ReplicaManagerInterface.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,13 @@ interface ReplicaManagerInterface
3131
* @throws NoSuchEntityException
3232
*/
3333
public function handleReplicas(string $primaryIndexName, int $storeId, array $primaryIndexSettings): void;
34+
35+
36+
/**
37+
* For standard Magento front end (e.g. Luma) replicas will likely only be needed if InstantSearch is enabled
38+
* Headless implementations may wish to override this behavior via plugin
39+
* @param int $storeId
40+
* @return bool
41+
*/
42+
public function isReplicaSyncEnabled(int $storeId): bool;
3443
}

Model/Product/ReplicaManager.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ protected function getMagentoReplicaSettingsFromConfig(string $primaryIndexName,
210210
*/
211211
public function handleReplicas(string $primaryIndexName, int $storeId, array $primaryIndexSettings): void
212212
{
213-
// TODO: InstantSearch enablement should not be a hard requirement (i.e. headless implementations may still need replicas) - add an override for this
214-
if ($this->configHelper->isInstantEnabled($storeId)
213+
if ($this->isReplicaSyncEnabled($storeId)
215214
&& $this->hasReplicaConfigurationChanged($primaryIndexName, $storeId)
216215
&& $this->isReplicaConfigurationValid($primaryIndexName, $storeId)) {
217216
$addedReplicas = $this->setReplicasOnPrimaryIndex($primaryIndexName, $storeId);
@@ -363,4 +362,12 @@ function($replica) use ($replicas) {
363362
}
364363
}
365364
}
365+
366+
/**
367+
* @inheritDoc
368+
*/
369+
public function isReplicaSyncEnabled(int $storeId): bool
370+
{
371+
return $this->configHelper->isInstantEnabled($storeId);
372+
}
366373
}

0 commit comments

Comments
 (0)