Skip to content

Commit a3f85ee

Browse files
authored
Merge branch 'develop' into release-3.10.1-prep
2 parents 0ba59d8 + 857be4c commit a3f85ee

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

Helper/Entity/CategoryHelper.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class CategoryHelper
5050
protected $categoryRepository;
5151

5252
protected $isCategoryVisibleInMenuCache;
53+
protected $coreCategories;
5354
protected $idColumn;
5455
protected $categoryAttributes;
5556
protected $rootCategoryId = -1;
@@ -548,7 +549,12 @@ public function isCategoryVisibleInMenu($categoryId, $storeId)
548549
*/
549550
public function getCoreCategories($filterNotIncludedCategories = true, $storeId = null)
550551
{
551-
$key = $filterNotIncludedCategories ? 'filtered' : 'non_filtered';
552+
// Cache category look up by store scope
553+
$key = ($filterNotIncludedCategories ? 'filtered' : 'non_filtered') . "-$storeId";
554+
555+
if (isset($this->coreCategories[$key])) {
556+
return $this->coreCategories[$key];
557+
}
552558

553559
$collection = $this->categoryCollectionFactory->create()
554560
->distinct(true)
@@ -562,14 +568,14 @@ public function getCoreCategories($filterNotIncludedCategories = true, $storeId
562568
$collection->addAttributeToFilter('include_in_menu', '1');
563569
}
564570

565-
$coreCategories[$key] = [];
571+
$this->coreCategories[$key] = [];
566572

567573
/** @var \Magento\Catalog\Model\Category $category */
568574
foreach ($collection as $category) {
569-
$coreCategories[$key][$category->getId()] = $category;
575+
$this->coreCategories[$key][$category->getId()] = $category;
570576
}
571577

572-
return $coreCategories[$key];
578+
return $this->coreCategories[$key];
573579
}
574580

575581
/**

Helper/Entity/ProductHelper.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,8 @@ public function setSettings($indexName, $indexNameTmp, $storeId, $saveToTmpIndic
485485
} else {
486486
foreach ($sortingIndices as $values) {
487487
$replicaName = $values['name'];
488-
array_unshift($customRanking,$values['ranking'][0]);
489-
$replicaSetting['customRanking'] = $customRanking;
488+
array_unshift($customRanking,$values['ranking'][0]);
489+
$replicaSetting['customRanking'] = $customRanking;
490490
$this->algoliaHelper->setSettings($replicaName, $replicaSetting, false, false);
491491
$this->logger->log('Setting settings to "' . $replicaName . '" replica.');
492492
$this->logger->log('Settings: ' . json_encode($replicaSetting));
@@ -502,6 +502,15 @@ public function setSettings($indexName, $indexNameTmp, $storeId, $saveToTmpIndic
502502
// $this->deleteUnusedReplicas($indexName, $replicas, $setReplicasTaskId);
503503

504504
if ($saveToTmpIndicesToo === true) {
505+
try {
506+
$this->algoliaHelper->copySynonyms($indexName, $indexNameTmp);
507+
$this->logger->log('
508+
Copying synonyms from production index to TMP one to not to erase them with the index move.
509+
');
510+
} catch (AlgoliaException $e) {
511+
$this->logger->error('Error encountered while copying synonyms: ' . $e->getMessage());
512+
}
513+
505514
try {
506515
$this->algoliaHelper->copyQueryRules($indexName, $indexNameTmp);
507516
$this->logger->log('

0 commit comments

Comments
 (0)