Skip to content

Commit 538b811

Browse files
authored
Merge pull request #1412 from algolia/release/3.11.0
Release/3.11.0
2 parents 907d089 + 19c9f39 commit 538b811

File tree

20 files changed

+774
-517
lines changed

20 files changed

+774
-517
lines changed

Block/Configuration.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ public function getConfiguration()
208208
'nbOfCategoriesSuggestions' => $config->getNumberOfCategoriesSuggestions(),
209209
'nbOfQueriesSuggestions' => $config->getNumberOfQueriesSuggestions(),
210210
'isDebugEnabled' => $config->isAutocompleteDebugEnabled(),
211-
'isNavigatorEnabled' => $config->isAutocompleteNavigatorEnabled()
211+
'isNavigatorEnabled' => $config->isAutocompleteNavigatorEnabled(),
212+
'debounceMilliseconds' => $config->getAutocompleteDebounceMilliseconds(),
213+
'minimumCharacters' => $config->getAutocompleteMinimumCharacterLength()
212214
],
213215
'landingPage' => [
214216
'query' => $this->getLandingPageQuery(),
@@ -267,7 +269,7 @@ public function getConfiguration()
267269
'autofocus' => true,
268270
'resultPageUrl' => $this->getCatalogSearchHelper()->getResultUrl(),
269271
'request' => [
270-
'query' => html_entity_decode($query),
272+
'query' => htmlspecialchars(html_entity_decode($query)),
271273
'refinementKey' => $refinementKey,
272274
'refinementValue' => $refinementValue,
273275
'categoryId' => $categoryId,

CHANGELOG.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
# CHANGE LOG
22

3-
## 3.11.0-beta
3+
## 3.11.0
44

5-
### Bug Fixes
5+
### Updates
66
- Support for Merch Studio and the Visual Merchandiser.
77
- Upgraded the Algolia PHP client to version 3.3.2
88
- Upgraded the Algolia insight 2.6.0
99
- Preserve facet selections after adding an item to the cart from the PLP
1010
- Fixes related to Neural Search compatibility
11+
- Added ability to hide Pagination when results have only one page in InstantSearch page
12+
- Increased the character limit of class field in algoliasearch_queue, algoliasearch_queue_archive table
13+
- Fixed vulnerability in query (htmlspecialcharacters) while searching using special characters
14+
- Fixed issues related to overlooked special characters in autocomplete search queries.
15+
- Fixed Bundle Product Price indexing issue for Dynamic and Static Product Types
16+
- Added ability to debounce and control the query length in autocomplete
17+
- Added ability to turn off suggestions and pages indexing
18+
- Added flattened categoryID attribute to product index to support Merchandising Studio
19+
20+
21+
22+
## 3.10.6
23+
24+
### Bug Fixes
25+
- Replaced referenceBlock by referenceContainer following Magento best practices.
26+
1127

1228
## 3.10.5
1329

Helper/AlgoliaHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function setSettings(
157157
public function deleteIndex($indexName)
158158
{
159159
$this->checkClient(__FUNCTION__);
160-
$res = $this->client->initIndex($indexName)->delete();
160+
$res = $this->client->initIndex($indexName)->delete()->wait();
161161

162162
self::setLastOperationInfo($indexName, $res);
163163
}

Helper/ConfigHelper.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class ConfigHelper
1616
{
1717
public const ENABLE_FRONTEND = 'algoliasearch_credentials/credentials/enable_frontend';
1818
public const ENABLE_BACKEND = 'algoliasearch_credentials/credentials/enable_backend';
19+
public const ENABLE_QUERY_SUGGESTIONS_INDEX = 'algoliasearch_credentials/credentials/enable_query_suggestions_index';
20+
public const ENABLE_PAGES_INDEX = 'algoliasearch_credentials/credentials/enable_pages_index';
1921
public const LOGGING_ENABLED = 'algoliasearch_credentials/credentials/debug';
2022
public const APPLICATION_ID = 'algoliasearch_credentials/credentials/application_id';
2123
public const API_KEY = 'algoliasearch_credentials/credentials/api_key';
@@ -45,6 +47,8 @@ class ConfigHelper
4547
public const MIN_NUMBER_OF_RESULTS = 'algoliasearch_autocomplete/autocomplete/min_number_of_results';
4648
public const RENDER_TEMPLATE_DIRECTIVES = 'algoliasearch_autocomplete/autocomplete/render_template_directives';
4749
public const AUTOCOMPLETE_MENU_DEBUG = 'algoliasearch_autocomplete/autocomplete/debug';
50+
public const AUTOCOMPLETE_DEBOUNCE_MILLISEC = 'algoliasearch_autocomplete/autocomplete/debounce_millisec';
51+
public const AUTOCOMPLETE_MINIMUM_CHAR_LENGTH = 'algoliasearch_autocomplete/autocomplete/minimum_char_length';
4852

4953
public const PRODUCT_ATTRIBUTES = 'algoliasearch_products/products/product_additional_attributes';
5054
public const PRODUCT_CUSTOM_RANKING = 'algoliasearch_products/products/custom_ranking_product_attributes';
@@ -954,6 +958,24 @@ public function isAutocompleteDebugEnabled($storeId = null)
954958
return $this->configInterface->isSetFlag(self::AUTOCOMPLETE_MENU_DEBUG, ScopeInterface::SCOPE_STORE, $storeId);
955959
}
956960

961+
public function getAutocompleteDebounceMilliseconds($storeId = null): int
962+
{
963+
return (int) $this->configInterface->getValue(
964+
self::AUTOCOMPLETE_DEBOUNCE_MILLISEC,
965+
ScopeInterface::SCOPE_STORE,
966+
$storeId
967+
);
968+
}
969+
970+
public function getAutocompleteMinimumCharacterLength($storeId = null): int
971+
{
972+
return (int) $this->configInterface->getValue(
973+
self::AUTOCOMPLETE_MINIMUM_CHAR_LENGTH,
974+
ScopeInterface::SCOPE_STORE,
975+
$storeId
976+
);
977+
}
978+
957979
/**
958980
* @param $originalIndexName
959981
* @param $storeId
@@ -1607,6 +1629,24 @@ public function getMaxRecordSizeLimit($storeId = null)
16071629
);
16081630
}
16091631

1632+
/**
1633+
* @param $storeId
1634+
* @return bool
1635+
*/
1636+
public function isQuerySuggestionsIndexEnabled($storeId = null)
1637+
{
1638+
return $this->configInterface->isSetFlag(self::ENABLE_QUERY_SUGGESTIONS_INDEX, ScopeInterface::SCOPE_STORE, $storeId);
1639+
}
1640+
1641+
/**
1642+
* @param $storeId
1643+
* @return bool
1644+
*/
1645+
public function isPagesIndexEnabled($storeId = null)
1646+
{
1647+
return $this->configInterface->isSetFlag(self::ENABLE_PAGES_INDEX, ScopeInterface::SCOPE_STORE, $storeId);
1648+
}
1649+
16101650
/**
16111651
* @param $storeId
16121652
* @return int

Helper/Data.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Data
7979
protected $emulationRuns = false;
8080

8181
/** @var \Magento\Framework\Indexer\IndexerInterface */
82-
private $priceIndexer;
82+
protected $priceIndexer;
8383

8484

8585
/**
@@ -260,6 +260,11 @@ public function rebuildStorePageIndex($storeId, array $pageIds = null)
260260
if ($this->isIndexingEnabled($storeId) === false) {
261261
return;
262262
}
263+
264+
if (!$this->configHelper->isPagesIndexEnabled($storeId)) {
265+
$this->logger->log('Pages Indexing is not enabled for the store.');
266+
return;
267+
}
263268

264269
$indexName = $this->getIndexName($this->pageHelper->getIndexNameSuffix(), $storeId);
265270

@@ -356,7 +361,12 @@ public function rebuildStoreCategoryIndex($storeId, $categoryIds = null)
356361
*/
357362
public function rebuildStoreSuggestionIndex($storeId)
358363
{
359-
if ($this->isIndexingEnabled($storeId) === false) {
364+
if ($this->isIndexingEnabled($storeId) === false || !$this->configHelper->isQuerySuggestionsIndexEnabled($storeId)) {
365+
return;
366+
}
367+
368+
if (!$this->configHelper->isQuerySuggestionsIndexEnabled($storeId)) {
369+
$this->logger->log('Query Suggestions Indexing is not enabled for the store.');
360370
return;
361371
}
362372

Helper/Entity/Product/PriceManager/Bundle.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,21 @@ protected function addAdditionalData($product, $withTax, $subProducts, $currency
4343
*/
4444
protected function getMinMaxPrices(Product $product, $withTax, $subProducts, $currencyCode)
4545
{
46-
$product->setData('website_id', $product->getStore()->getWebsiteId());
47-
$minPrice = $product->getPriceInfo()->getPrice('final_price')->getMinimalPrice()->getValue();
48-
$minOriginalPrice = $product->getPriceInfo()->getPrice('regular_price')->getMinimalPrice()->getValue();
49-
$maxOriginalPrice = $product->getPriceInfo()->getPrice('regular_price')->getMaximalPrice()->getValue();
50-
$max = $product->getPriceInfo()->getPrice('final_price')->getMaximalPrice()->getValue();
46+
$productWithPrice = $this->productloader->create()->load($product->getId());
47+
$productWithPrice->setData('website_id', $product->getStore()->getWebsiteId());
48+
$minPrice = $productWithPrice->getPriceInfo()->getPrice('final_price')->getMinimalPrice()->getValue();
49+
$minOriginalPrice = $productWithPrice->getPriceInfo()->getPrice('regular_price')->getMinimalPrice()->getValue();
50+
$maxOriginalPrice = $productWithPrice->getPriceInfo()->getPrice('regular_price')->getMaximalPrice()->getValue();
51+
$max = $productWithPrice->getPriceInfo()->getPrice('final_price')->getMaximalPrice()->getValue();
5152
$minArray = [];
5253
$maxArray = [];
5354
foreach ($this->groups as $group) {
5455
$groupId = (int) $group->getData('customer_group_id');
55-
$product->setData('customer_group_id', $groupId);
56-
$minPrice = $product->getPriceInfo()->getPrice('final_price')->getMinimalPrice()->getValue();
57-
$minArray[$groupId] = $product->getPriceInfo()->getPrice('final_price')->getMinimalPrice()->getValue();
58-
$maxArray[$groupId] = $product->getPriceInfo()->getPrice('final_price')->getMaximalPrice()->getValue();
59-
$product->setData('customer_group_id', null);
56+
$productWithPrice->setData('customer_group_id', $groupId);
57+
$minPrice = $productWithPrice->getPriceInfo()->getPrice('final_price')->getMinimalPrice()->getValue();
58+
$minArray[$groupId] = $productWithPrice->getPriceInfo()->getPrice('final_price')->getMinimalPrice()->getValue();
59+
$maxArray[$groupId] = $productWithPrice->getPriceInfo()->getPrice('final_price')->getMaximalPrice()->getValue();
60+
$productWithPrice->setData('customer_group_id', null);
6061
}
6162

6263
$minPriceArray = [];
@@ -152,4 +153,4 @@ protected function setFinalGroupPricesBundle($field, $currencyCode, $min, $max,
152153
}
153154
}
154155
}
155-
}
156+
}

Helper/Entity/Product/PriceManager/ProductWithoutChildren.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function addPriceData($customData, Product $product, $subProducts): array
9090
$this->customData = $customData;
9191
$this->store = $product->getStore();
9292
$this->areCustomersGroupsEnabled = $this->configHelper->isCustomerGroupsEnabled($product->getStoreId());
93-
$currencies = $this->store->getAvailableCurrencyCodes();
93+
$currencies = $this->store->getAvailableCurrencyCodes(true);
9494
$this->baseCurrencyCode = $this->store->getBaseCurrencyCode();
9595
$this->groups = $this->customerGroupCollectionFactory->create();
9696
$fields = $this->getFields();

Model/Indexer/Page.php

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,49 @@
1313

1414
class Page implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface
1515
{
16-
private $fullAction;
17-
private $storeManager;
18-
private $pageHelper;
19-
private $algoliaHelper;
20-
private $queue;
21-
private $configHelper;
22-
private $messageManager;
23-
private $output;
24-
16+
/**
17+
* @var Data
18+
*/
19+
protected $fullAction;
20+
/**
21+
* @var StoreManagerInterface
22+
*/
23+
protected $storeManager;
24+
/**
25+
* @var PageHelper
26+
*/
27+
protected $pageHelper;
28+
/**
29+
* @var AlgoliaHelper
30+
*/
31+
protected $algoliaHelper;
32+
/**
33+
* @var Queue
34+
*/
35+
protected $queue;
36+
/**
37+
* @var ConfigHelper
38+
*/
39+
protected $configHelper;
40+
/**
41+
* @var ManagerInterface
42+
*/
43+
protected $messageManager;
44+
/**
45+
* @var ConsoleOutput
46+
*/
47+
protected $output;
48+
49+
/**
50+
* @param StoreManagerInterface $storeManager
51+
* @param PageHelper $pageHelper
52+
* @param Data $helper
53+
* @param AlgoliaHelper $algoliaHelper
54+
* @param Queue $queue
55+
* @param ConfigHelper $configHelper
56+
* @param ManagerInterface $messageManager
57+
* @param ConsoleOutput $output
58+
*/
2559
public function __construct(
2660
StoreManagerInterface $storeManager,
2761
PageHelper $pageHelper,
@@ -42,6 +76,10 @@ public function __construct(
4276
$this->output = $output;
4377
}
4478

79+
/**
80+
* @param $ids
81+
* @return void
82+
*/
4583
public function execute($ids)
4684
{
4785
if (!$this->configHelper->getApplicationID()
@@ -84,22 +122,37 @@ public function execute($ids)
84122
}
85123
}
86124

125+
/**
126+
* @return void
127+
*/
87128
public function executeFull()
88129
{
89130
$this->execute(null);
90131
}
91132

133+
/**
134+
* @param array $ids
135+
* @return void
136+
*/
92137
public function executeList(array $ids)
93138
{
94139
$this->execute($ids);
95140
}
96141

142+
/**
143+
* @param $id
144+
* @return void
145+
*/
97146
public function executeRow($id)
98147
{
99148
$this->execute([$id]);
100149
}
101150

102-
private function isPagesInAdditionalSections($storeId)
151+
/**
152+
* @param $storeId
153+
* @return bool
154+
*/
155+
protected function isPagesInAdditionalSections($storeId)
103156
{
104157
$sections = $this->configHelper->getAutocompleteSections($storeId);
105158
foreach ($sections as $section) {

0 commit comments

Comments
 (0)