Skip to content

Commit 5a28d9f

Browse files
committed
MAGE-848 Ensure comparisons against Algolia replica config are always checking the latest possible sorting index config in Magento
1 parent ff7ddc0 commit 5a28d9f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Service/Product/ReplicaManager.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ protected function hasReplicaConfigurationChanged(int $storeId): bool
8686
default:
8787
$primaryIndexName = $this->indexNameFetcher->getProductIndexName($storeId);
8888
$old = $this->getMagentoReplicaConfigurationFromAlgolia($primaryIndexName);
89-
$new = $this->sortingTransformer->transformSortingIndicesToReplicaSetting($this->sortingTransformer->getSortingIndices($storeId));
89+
$new = $this->sortingTransformer->transformSortingIndicesToReplicaSetting(
90+
$this->sortingTransformer->getSortingIndices($storeId, null, null, true)
91+
);
9092
sort($old);
9193
sort($new);
9294
return $old !== $new;

Service/Product/SortingTransformer.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,25 @@ public function __construct(
3838
* @param ?int $storeId
3939
* @param ?int $currentCustomerGroupId
4040
* @param ?array $attrs - serialized array of sorting attributes to transform (defaults to saved sorting config)
41+
* @param bool $clearCache - If set to true will update the cache
4142
* @return array of transformed sorting / replica objects
4243
* @throws LocalizedException
4344
* @throws NoSuchEntityException
4445
*/
4546
public function getSortingIndices(
4647
?int $storeId = null,
4748
?int $currentCustomerGroupId = null,
48-
?array $attrs = null
49+
?array $attrs = null,
50+
bool $clearCache = false
4951
): array
5052
{
5153
// Selectively cache this result - only cache manipulation of saved settings per store
5254
$useCache = is_null($currentCustomerGroupId) && is_null($attrs);
5355

56+
if ($clearCache) {
57+
unset($this->_sortingIndices[$storeId]);
58+
}
59+
5460
if ($useCache
5561
&& array_key_exists($storeId, $this->_sortingIndices)
5662
&& is_array($this->_sortingIndices[$storeId])) {

0 commit comments

Comments
 (0)