Skip to content

Commit 037122f

Browse files
authored
Merge branch 'release/3.12.0' into update/MAGE-798
2 parents 0c918c5 + 3b54b49 commit 037122f

File tree

6 files changed

+62
-70
lines changed

6 files changed

+62
-70
lines changed

Helper/Entity/ProductHelper.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ public function setSettings($indexName, $indexNameTmp, $storeId, $saveToTmpIndic
463463

464464
// Managing Virtual Replica
465465
if ($this->configHelper->useVirtualReplica($storeId)) {
466-
$replicas = $this->handleVirtualReplica($replicas, $indexName);
466+
$replicas = $this->handleVirtualReplica($replicas);
467467
}
468468

469469
// Merge current replicas with sorting replicas to not delete A/B testing replica indices
@@ -773,9 +773,11 @@ protected function getValidCategoryName($category, $rootCat, $storeId): ?string
773773
*/
774774
protected function dedupePaths($paths): array
775775
{
776-
return array_intersect_key(
777-
$paths,
778-
array_unique(array_map('serialize', $paths))
776+
return array_values(
777+
array_intersect_key(
778+
$paths,
779+
array_unique(array_map('serialize', $paths))
780+
)
779781
);
780782
}
781783

@@ -1229,7 +1231,7 @@ protected function addNonNullValue(
12291231
$value = $attributeResource->getFrontend()->getValue($product);
12301232
}
12311233

1232-
if ($value) {
1234+
if ($value !== null) {
12331235
$customData[$attribute['attribute']] = $value;
12341236
}
12351237

@@ -1532,7 +1534,7 @@ public function productIsInStock($product, $storeId)
15321534
* @param $replica
15331535
* @return array
15341536
*/
1535-
public function handleVirtualReplica($replicas, $indexName)
1537+
public function handleVirtualReplica($replicas)
15361538
{
15371539
$virtualReplicaArray = [];
15381540
foreach ($replicas as $replica) {
@@ -1556,12 +1558,14 @@ public function handlingReplica($indexName, $storeId, $sortingAttribute = false)
15561558
return $sortingIndex['name'];
15571559
}, $sortingIndices));
15581560
try {
1561+
$replicasFormated = $this->handleVirtualReplica($replicas);
1562+
$availableReplicaMatch = array_merge($replicasFormated, $replicas);
15591563
if ($this->configHelper->useVirtualReplica($storeId)) {
1560-
$replicas = $this->handleVirtualReplica($replicas, $indexName);
1564+
$replicas = $replicasFormated;
15611565
}
15621566
$currentSettings = $this->algoliaHelper->getSettings($indexName);
15631567
if (is_array($currentSettings) && array_key_exists('replicas', $currentSettings)) {
1564-
$replicasRequired = array_values(array_diff_assoc($currentSettings['replicas'], $replicas));
1568+
$replicasRequired = array_values(array_diff($currentSettings['replicas'], $availableReplicaMatch));
15651569
$this->algoliaHelper->setSettings($indexName, ['replicas' => $replicasRequired]);
15661570
$setReplicasTaskId = $this->algoliaHelper->getLastTaskId();
15671571
$this->algoliaHelper->waitLastTask($indexName, $setReplicasTaskId);

Model/Backend/Sorts.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ public function afterSave()
7474
if ($this->isValueChanged()) {
7575
try{
7676
$oldValue = $this->serializer->unserialize($this->getOldValue());
77+
$updatedValue = $this->serializer->unserialize($this->getValue());
78+
$sortingAttributes = array_merge($oldValue, $updatedValue);
7779
$storeIds = array_keys($this->storeManager->getStores());
7880
foreach ($storeIds as $storeId) {
7981
$indexName = $this->helper->getIndexName($this->productHelper->getIndexNameSuffix(), $storeId);
80-
$this->productHelper->handlingReplica($indexName, $storeId, $oldValue);
82+
$this->productHelper->handlingReplica($indexName, $storeId, $sortingAttributes);
8183
}
8284
} catch (AlgoliaException $e) {
8385
if ($e->getCode() !== 404) {

Model/Observer/Merchandising.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function execute(Observer $observer)
6767
The category cannot be merchandised with Algolia
6868
as you hit your <a href="https://www.algolia.com/pricing/" target="_blank">query rules quota</a>.
6969
If you need an extended quota,
70-
please contact us on <a href="mailto:support@algolia.com">support@algolia.com</a>.';
70+
please reach out to the [Algolia Support team](https://support.algolia.com/hc/en-us/requests/new).';
7171
}
7272

7373
$phrase = new Phrase($message);

view/frontend/web/instantsearch.js

Lines changed: 44 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -300,46 +300,47 @@ define(
300300
return item;
301301
});
302302
},
303+
},
303304

304-
/*
305-
* clearRefinements
306-
* Widget displays a button that lets the user clean every refinement applied to the search. You can control which attributes are impacted by the button with the options.
307-
* Docs: https://www.algolia.com/doc/api-reference/widgets/clear-refinements/js/
308-
**/
309-
clearRefinements: {
310-
container : '#clear-refinements',
311-
templates : {
312-
resetLabel: algoliaConfig.translations.clearAll,
313-
},
314-
includedAttributes: attributes.map(function (attribute) {
315-
if (!(algoliaConfig.isCategoryPage && attribute.name.indexOf('categories') > -1)) {
316-
return attribute.name;
317-
}
318-
}),
319-
cssClasses : {
320-
button: ['action', 'primary']
321-
},
322-
transformItems : function (items) {
323-
return items.map(function (item) {
324-
var attribute = attributes.filter(function (_attribute) {
325-
return item.attribute === _attribute.name
326-
})[0];
327-
if (!attribute) return item;
328-
item.label = attribute.label;
329-
return item;
330-
})
305+
/*
306+
* clearRefinements
307+
* Widget displays a button that lets the user clean every refinement applied to the search. You can control which attributes are impacted by the button with the options.
308+
* Docs: https://www.algolia.com/doc/api-reference/widgets/clear-refinements/js/
309+
**/
310+
clearRefinements: {
311+
container : '#clear-refinements',
312+
templates : {
313+
resetLabel: algoliaConfig.translations.clearAll,
314+
},
315+
includedAttributes: attributes.map(function (attribute) {
316+
if (!(algoliaConfig.isCategoryPage && attribute.name.indexOf('categories') > -1)) {
317+
return attribute.name;
331318
}
319+
}),
320+
cssClasses : {
321+
button: ['action', 'primary']
332322
},
333-
/*
334-
* queryRuleCustomData
335-
* The queryRuleCustomData widget displays custom data from Query Rules.
336-
* Docs: https://www.algolia.com/doc/api-reference/widgets/query-rule-custom-data/js/
337-
**/
338-
queryRuleCustomData: {
339-
container: '#algolia-banner',
340-
templates: {
323+
transformItems : function (items) {
324+
return items.map(function (item) {
325+
var attribute = attributes.filter(function (_attribute) {
326+
return item.attribute === _attribute.name
327+
})[0];
328+
if (!attribute) return item;
329+
item.label = attribute.label;
330+
return item;
331+
})
332+
}
333+
},
334+
335+
/*
336+
* queryRuleCustomData
337+
* The queryRuleCustomData widget displays custom data from Query Rules.
338+
* Docs: https://www.algolia.com/doc/api-reference/widgets/query-rule-custom-data/js/
339+
**/
340+
queryRuleCustomData: {
341+
container: '#algolia-banner',
342+
templates: {
341343
default: '{{#items}} {{#banner}} {{{banner}}} {{/banner}} {{/items}}',
342-
}
343344
}
344345
}
345346
};
@@ -447,40 +448,25 @@ define(
447448
* Custom widgets can be added to this object like [attribute]: function(facet, templates)
448449
* Function must return an array [<widget name>: string, <widget options>: object]
449450
**/
450-
var customAttributeFacet = {
451+
const customAttributeFacet = {
451452
categories: function (facet, templates) {
452-
var hierarchical_levels = [];
453-
for (var l = 0; l < 10; l++) {
453+
const hierarchical_levels = [];
454+
for (let l = 0; l < 10; l++) {
454455
hierarchical_levels.push('categories.level' + l.toString());
455456
}
456457

457-
458-
//return array of items starting from root based on category
459-
const findRoot = (items) => {
460-
const root = items.find(element => algoliaConfig.request.path.startsWith(element.value));
461-
462-
if (!root) {
463-
return items;
464-
}
465-
if (!root.data) {
466-
return [];
467-
}
468-
469-
return findRoot(root.data);
470-
471-
};
472-
473-
var hierarchicalMenuParams = {
458+
const hierarchicalMenuParams = {
474459
container : facet.wrapper.appendChild(createISWidgetContainer(facet.attribute)),
475460
attributes : hierarchical_levels,
476461
separator : algoliaConfig.instant.categorySeparator,
477462
templates : templates,
478463
showParentLevel : true,
479464
limit : algoliaConfig.maxValuesPerFacet,
465+
rootPath : algoliaConfig.request.path,
480466
sortBy : ['name:asc'],
481467
transformItems(items) {
482468
return (algoliaConfig.isCategoryPage)
483-
? findRoot(items).map(
469+
? items.map(
484470
item => {
485471
return {
486472
...item,
@@ -727,4 +713,4 @@ define(
727713
return options;
728714
}
729715
}
730-
);
716+
);

view/frontend/web/internals/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ define(['jquery', 'algoliaBundle'], function ($, algoliaBundle) {
405405
if (algoliaConfig.isLandingPage &&
406406
typeof uiStateProductIndex['hierarchicalMenu']['categories.level0'] === 'undefined' &&
407407
'categories.level0' in landingPageConfig) {
408-
uiStateProductIndex['hierarchicalMenu']['categories.level0'] = landingPageConfig['categories.level0'].split(' /// ');
408+
uiStateProductIndex['hierarchicalMenu']['categories.level0'] = landingPageConfig['categories.level0'].split(algoliaConfig.instant.categorySeparator);
409409
}
410410
}
411411
if (currentFacet.attribute == 'categories' && algoliaConfig.isCategoryPage) {

view/frontend/web/internals/template/autocomplete/products.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ define([], function () {
7373
const priceGroup = algoliaConfig.priceGroup || 'default';
7474

7575
return html `<div className="algoliasearch-autocomplete-price">
76-
<span className="after_special ${algoliaConfig.origFormatedVar != null ? 'promotion' : ''}">
76+
<span className="after_special ${item['price'][algoliaConfig.currencyCode][priceGroup + '_original_formated'] != null ? 'promotion' : ''}">
7777
${item['price'][algoliaConfig.currencyCode][priceGroup + '_formated']}
7878
</span>
7979
${this.getOriginalPriceHtml(item, html, priceGroup)}

0 commit comments

Comments
 (0)