Skip to content

Commit

Permalink
Merge pull request #1315 from algolia/develop
Browse files Browse the repository at this point in the history
Release/3.10.1 Hotfix
  • Loading branch information
mohitalgolia authored Mar 8, 2023
2 parents a3cee3d + 2788ec8 commit b0fc4de
Show file tree
Hide file tree
Showing 19 changed files with 71 additions and 42 deletions.
1 change: 1 addition & 0 deletions Block/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ public function getConfiguration()
'relevance' => __('Relevance'),
'categories' => __('Categories'),
'products' => __('Products'),
'suggestions' => __('Suggestions'),
'searchBy' => __('Search by'),
'searchForFacetValuesPlaceholder' => __('Search for other ...'),
'showMore' => __('Show more products'),
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# CHANGE LOG

## 3.10.1

### UPDATES
- Added recommended js version in readme file.

### Bug Fixes
- Add caching on category name lookup (scoped by store) to fix slowness in indexing.
- Prevent loss of synonyms while copying from tmp index during Indexing in Algolia Dashboard.
- Fixed the translation issue of labels in Algolia autocomplete dropdown
- Ensured compatibility of the extension with PHP 7.4
- Resolved the deployment issue related to prefixing Magento database tables


## 3.10.0

Expand Down
14 changes: 10 additions & 4 deletions Helper/Entity/CategoryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class CategoryHelper
protected $categoryRepository;

protected $isCategoryVisibleInMenuCache;
protected $coreCategories;
protected $idColumn;
protected $categoryAttributes;
protected $rootCategoryId = -1;
Expand Down Expand Up @@ -548,7 +549,12 @@ public function isCategoryVisibleInMenu($categoryId, $storeId)
*/
public function getCoreCategories($filterNotIncludedCategories = true, $storeId = null)
{
$key = $filterNotIncludedCategories ? 'filtered' : 'non_filtered';
// Cache category look up by store scope
$key = ($filterNotIncludedCategories ? 'filtered' : 'non_filtered') . "-$storeId";

if (isset($this->coreCategories[$key])) {
return $this->coreCategories[$key];
}

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

$coreCategories[$key] = [];
$this->coreCategories[$key] = [];

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

return $coreCategories[$key];
return $this->coreCategories[$key];
}

/**
Expand Down
13 changes: 11 additions & 2 deletions Helper/Entity/ProductHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ public function setSettings($indexName, $indexNameTmp, $storeId, $saveToTmpIndic
} else {
foreach ($sortingIndices as $values) {
$replicaName = $values['name'];
array_unshift($customRanking,$values['ranking'][0]);
$replicaSetting['customRanking'] = $customRanking;
array_unshift($customRanking,$values['ranking'][0]);
$replicaSetting['customRanking'] = $customRanking;
$this->algoliaHelper->setSettings($replicaName, $replicaSetting, false, false);
$this->logger->log('Setting settings to "' . $replicaName . '" replica.');
$this->logger->log('Settings: ' . json_encode($replicaSetting));
Expand All @@ -502,6 +502,15 @@ public function setSettings($indexName, $indexNameTmp, $storeId, $saveToTmpIndic
// $this->deleteUnusedReplicas($indexName, $replicas, $setReplicasTaskId);

if ($saveToTmpIndicesToo === true) {
try {
$this->algoliaHelper->copySynonyms($indexName, $indexNameTmp);
$this->logger->log('
Copying synonyms from production index to TMP one to not erase them with the index move.
');
} catch (AlgoliaException $e) {
$this->logger->error('Error encountered while copying synonyms: ' . $e->getMessage());
}

try {
$this->algoliaHelper->copyQueryRules($indexName, $indexNameTmp);
$this->logger->log('
Expand Down
12 changes: 6 additions & 6 deletions Observer/Insights/CheckoutCartProductAddAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ class CheckoutCartProductAddAfter implements ObserverInterface
{

/** @var Data */
protected Data $dataHelper;
protected $dataHelper;

/** @var InsightsHelper */
protected InsightsHelper $insightsHelper;
protected $insightsHelper;

/** @var LoggerInterface */
protected LoggerInterface $logger;
protected $logger;

/** @var ConfigHelper */
protected ConfigHelper $configHelper;
protected $configHelper;

/** @var PersonalizationHelper */
private PersonalizationHelper $personalizationHelper;
protected $personalizationHelper;

/** @var SessionManagerInterface */
protected SessionManagerInterface $coreSession;
protected $coreSession;

/**
* @param Data $dataHelper
Expand Down
2 changes: 1 addition & 1 deletion Observer/Insights/CheckoutCartProductAddBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class CheckoutCartProductAddBefore implements ObserverInterface
{
/** @var SessionManagerInterface */
protected SessionManagerInterface $coreSession;
protected $coreSession;

/**
* @param SessionManagerInterface $coreSession
Expand Down
10 changes: 5 additions & 5 deletions Observer/Insights/CheckoutOnepageControllerSuccessAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
class CheckoutOnepageControllerSuccessAction implements ObserverInterface
{
/** @var Data */
protected Data $dataHelper;
protected $dataHelper;

/** @var InsightsHelper */
protected InsightsHelper $insightsHelper;
protected $insightsHelper;

/** @var OrderFactory */
protected OrderFactory $orderFactory;
protected $orderFactory;

/** @var LoggerInterface */
protected LoggerInterface $logger;
protected $logger;

/** @var ConfigHelper */
protected ConfigHelper $configHelper;
protected $configHelper;

/**
* @param Data $dataHelper
Expand Down
2 changes: 1 addition & 1 deletion Observer/Insights/CustomerLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CustomerLogin implements ObserverInterface
{

/** @var InsightsHelper */
protected InsightsHelper $insightsHelper;
protected $insightsHelper;

/**
* @param InsightsHelper $insightsHelper
Expand Down
8 changes: 4 additions & 4 deletions Observer/Insights/WishlistProductAddAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
class WishlistProductAddAfter implements ObserverInterface
{
/** @var Data */
protected Data $dataHelper;
protected $dataHelper;

/** @var PersonalizationHelper */
protected PersonalizationHelper $personalisationHelper;
protected $personalisationHelper;

/** @var InsightsHelper */
protected InsightsHelper $insightsHelper;
protected $insightsHelper;

/** @var LoggerInterface */
protected LoggerInterface $logger;
protected $logger;

/**
* CheckoutCartProductAddAfter constructor.
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Algolia Search for Magento 2
==================

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

![PHP](https://img.shields.io/badge/PHP-8.1,7.4-blue)
Expand Down Expand Up @@ -89,12 +89,13 @@ These libraries are here to help add to your customisation but because the exten
#### The Extension JS Bundle
Knowing the version of the library will help you understand what is available in these libraries for you to leverage in terms of customisation. This table will help you determine which documentation to reference when you start working on your customisation.

| Extension Version | autocomplete.js | instantsearch.js | search-insights.js |
|-------------------|-------------------------------------------------------------------| --- | --- |
| v1.x | [0.26.0](https://github.com/algolia/autocomplete.js/tree/v0.26.0) | [2.10.2](https://github.com/algolia/instantsearch.js/tree/v2.10.2) | [0.0.14](https://cdn.jsdelivr.net/npm/[email protected]) |
| v2.x | [0.38.0](https://github.com/algolia/autocomplete.js/tree/v0.38.0) | [4.7.2](https://github.com/algolia/instantsearch.js/tree/v4.7.2) | [1.4.0](https://github.com/algolia/search-insights.js/tree/v1.4.0) |
| v3.x | [0.38.0](https://github.com/algolia/autocomplete.js/tree/v0.38.0) | [4.15.0](https://github.com/algolia/instantsearch.js/tree/v4.15.0) | [1.7.1](https://github.com/algolia/search-insights.js/tree/v1.7.1) |
| v3.8.x | [1.6.3](https://github.com/algolia/autocomplete.js/tree/v1.6.3) | [4.41.0](https://github.com/algolia/instantsearch.js/tree/v4.41.0) | [1.7.1](https://github.com/algolia/search-insights.js/tree/v1.7.1) |
| Extension Version | autocomplete.js | instantsearch.js | search-insights.js | recommend.js |
|-------------------|-------------------------------------------------------------------| --- | --- | --- |
| v1.x | [0.26.0](https://github.com/algolia/autocomplete.js/tree/v0.26.0) | [2.10.2](https://github.com/algolia/instantsearch.js/tree/v2.10.2) | [0.0.14](https://cdn.jsdelivr.net/npm/[email protected]) | NA |
| v2.x | [0.38.0](https://github.com/algolia/autocomplete.js/tree/v0.38.0) | [4.7.2](https://github.com/algolia/instantsearch.js/tree/v4.7.2) | [1.4.0](https://github.com/algolia/search-insights.js/tree/v1.4.0) | NA |
| v3.x | [0.38.0](https://github.com/algolia/autocomplete.js/tree/v0.38.0) | [4.15.0](https://github.com/algolia/instantsearch.js/tree/v4.15.0) | [1.7.1](https://github.com/algolia/search-insights.js/tree/v1.7.1) | NA |
| v3.9.1 | [1.6.3](https://github.com/algolia/autocomplete.js/tree/v1.6.3) | [4.41.0](https://github.com/algolia/instantsearch.js/tree/v4.41.0) | [1.7.1](https://github.com/algolia/search-insights.js/tree/v1.7.1) | [1.5.0](https://github.com/algolia/recommend/tree/v1.5.0) |
| v3.10.x | [1.6.3](https://github.com/algolia/autocomplete.js/tree/v1.6.3) | [4.41.0](https://github.com/algolia/instantsearch.js/tree/v4.41.0) | [1.7.1](https://github.com/algolia/search-insights.js/tree/v1.7.1) | [1.8.0](https://github.com/algolia/recommend/tree/v1.8.0) |

The autocomplete and instantsearch libraries are accessible in the `algoliaBundle` global. This bundle is a prepackage javascript file that contains it's dependencies. What is included in this bundle can be seen here:

Expand Down
2 changes: 1 addition & 1 deletion Setup/Patch/Schema/AutocompleteConfigPatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function apply()
];
$this->moduleDataSetup->getConnection()->startSetup();
$connection = $this->moduleDataSetup->getConnection();
$table = $connection->getTableName('core_config_data');
$table = $this->moduleDataSetup->getTable('core_config_data');
foreach ($movedConfigDirectives as $from => $to) {
try {
$connection->query('UPDATE ' . $table . ' SET path = "' . $to . '" WHERE path = "' . $from . '"');
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Algolia Search integration for Magento 2",
"type": "magento2-module",
"license": ["MIT"],
"version": "3.10.0",
"version": "3.10.1",
"require": {
"magento/framework": "~102.0|~103.0",
"algolia/algoliasearch-client-php": "3.2",
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Algolia_AlgoliaSearch" setup_version="3.10.0">
<module name="Algolia_AlgoliaSearch" setup_version="3.10.1">
<sequence>
<module name="Magento_Theme"/>
<module name="Magento_Backend"/>
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/web/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ define(
}

if (algoliaConfig.autocomplete.nbOfQueriesSuggestions > 0) {
algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: algoliaConfig.autocomplete.nbOfQueriesSuggestions, label: '', name: "suggestions"});
algoliaConfig.autocomplete.sections.unshift({ hitsPerPage: algoliaConfig.autocomplete.nbOfQueriesSuggestions, label: algoliaConfig.translations.suggestions, name: "suggestions"});
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
define([], function () {
return {
getNoResultHtml: function ({html}) {
return html`<p>No Results</p>`;
return html`<p>${algoliaConfig.translations.noResults}</p>`;
},

getHeaderHtml: function ({section}) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
define([], function () {
return {
getNoResultHtml: function ({html}) {
return html`<p>No Results</p>`;
return html`<p>${algoliaConfig.translations.noResults}</p>`;
},

getHeaderHtml: function ({section}) {
return section.name;
return section.label;
},

getItemHtml: function ({item, components, html}) {
Expand Down
4 changes: 2 additions & 2 deletions view/frontend/web/internals/template/autocomplete/pages.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
define([], function () {
return {
getNoResultHtml: function ({html}) {
return html`<p>No Results</p>`;
return html`<p>${algoliaConfig.translations.noResults}</p>`;
},

getHeaderHtml: function ({section}) {
return section.label || section.name;
return section.label;
},

getItemHtml: function ({item, components, html}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ define([], function () {
////////////////////

getNoResultHtml: function ({html}) {
return html`<p>No Results</p>`;
return html`<p>${algoliaConfig.translations.noResults}</p>`;
},

getHeaderHtml: function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
define([], function () {
return {
getNoResultHtml: function ({html}) {
return html`<p>No Results</p>`;
return html`<p>${algoliaConfig.translations.noResults}</p>`;
},

getHeaderHtml: function ({section}) {
return section.name;
return section.label;
},

getItemHtml: function ({item, html}) {
Expand Down

0 comments on commit b0fc4de

Please sign in to comment.