Skip to content

Commit 6c4b4f9

Browse files
authored
Merge branch 'develop' into bugfix/MAGE-558
2 parents 85e53c4 + de94943 commit 6c4b4f9

File tree

6 files changed

+29
-9
lines changed

6 files changed

+29
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CHANGE LOG
22

3+
## 3.10.1
4+
5+
### FIXES
6+
- Add caching on category name lookup (scoped by store) to fix sloness in indexing.
7+
- Preserve synonyms on tmp index copy after deprecated from the Magento.
38

49
## 3.10.0
510

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('

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Algolia Search for Magento 2
22
==================
33

4-
![Latest version](https://img.shields.io/badge/latest-3.10.0-green)
4+
![Latest version](https://img.shields.io/badge/latest-3.10.1-green)
55
![Magento 2](https://img.shields.io/badge/Magento-2.4.x-orange)
66

77
![PHP](https://img.shields.io/badge/PHP-8.1,7.4-blue)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Algolia Search integration for Magento 2",
44
"type": "magento2-module",
55
"license": ["MIT"],
6-
"version": "3.10.0",
6+
"version": "3.10.1",
77
"require": {
88
"magento/framework": "~102.0|~103.0",
99
"algolia/algoliasearch-client-php": "3.2",

etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="Algolia_AlgoliaSearch" setup_version="3.10.0">
3+
<module name="Algolia_AlgoliaSearch" setup_version="3.10.1">
44
<sequence>
55
<module name="Magento_Theme"/>
66
<module name="Magento_Backend"/>

0 commit comments

Comments
 (0)