Skip to content

Commit 588b96c

Browse files
authored
Merge pull request #1852 from algolia/fix/MAGE-1455-missing-price-values-3.16
MAGE-1455 Handle missing price values 3.16
2 parents 681b263 + 7528d41 commit 588b96c

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
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.16.2
4+
5+
### Bug fixes
6+
- Fixed issue where missing pricing keys were not handled gracefully in the Autocomplete product template
7+
38
## 3.16.1
49

510
### Updates

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Algolia Search & Discovery extension for Magento 2",
44
"type": "magento2-module",
55
"license": ["MIT"],
6-
"version": "3.16.1",
6+
"version": "3.16.2-dev",
77
"require": {
88
"php": "~8.2|~8.3|~8.4",
99
"magento/framework": "~103.0",

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.16.1">
3+
<module name="Algolia_AlgoliaSearch" setup_version="3.16.2-dev">
44
<sequence>
55
<module name="Magento_Theme"/>
66
<module name="Magento_Backend"/>

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,40 +45,40 @@ define([], function () {
4545

4646
getColorHtml: function(item, components, html) {
4747
const highlight = this.safeHighlight(components, item, "color");
48-
49-
return highlight
48+
49+
return highlight
5050
? html`<span class="color">color: ${highlight}</span>`
5151
: "";
5252
},
5353

5454
getCategoriesHtml: function(item, components, html) {
5555
const highlight = this.safeHighlight(components, item, "categories_without_path", false);
5656

57-
return highlight
57+
return highlight
5858
? html`<span>in ${highlight}</span>`
5959
: "";
6060
},
6161

6262
getOriginalPriceHtml: (item, html, priceGroup) => {
63-
if (item['price'][algoliaConfig.currencyCode][priceGroup + '_original_formated'] == null) return "";
63+
if (item['price']?.[algoliaConfig.currencyCode]?.[priceGroup + '_original_formated'] == null) return "";
6464

6565
return html`<span class="before_special"> ${item['price'][algoliaConfig.currencyCode][priceGroup + '_original_formated']} </span>`;
6666
},
6767

6868
getTierPriceHtml: (item, html, priceGroup) => {
69-
if (item['price'][algoliaConfig.currencyCode][priceGroup + '_tier_formated'] == null) return "";
69+
if (item['price']?.[algoliaConfig.currencyCode]?.[priceGroup + '_tier_formated'] == null) return "";
7070

7171
return html`<span class="tier_price"> As low as <span class="tier_value">${item['price'][algoliaConfig.currencyCode][priceGroup + '_tier_formated']}</span></span>`;
7272
},
7373

7474
getPricingHtml: function(item, html) {
75-
if (item['price'] == undefined) return "";
75+
if (item['price'] == null) return "";
7676

7777
const priceGroup = algoliaConfig.priceGroup || 'default';
7878

7979
return html `<div className="algoliasearch-autocomplete-price">
80-
<span className="after_special ${item['price'][algoliaConfig.currencyCode][priceGroup + '_original_formated'] != null ? 'promotion' : ''}">
81-
${item['price'][algoliaConfig.currencyCode][priceGroup + '_formated']}
80+
<span className="after_special ${item['price']?.[algoliaConfig.currencyCode]?.[priceGroup + '_original_formated'] != null ? 'promotion' : ''}">
81+
${item['price']?.[algoliaConfig.currencyCode]?.[priceGroup + '_formated']}
8282
</span>
8383
${this.getOriginalPriceHtml(item, html, priceGroup)}
8484
@@ -87,7 +87,7 @@ define([], function () {
8787
},
8888

8989
getFooterSearchCategoryLinks: (html, resultDetails) => {
90-
if (resultDetails.allCategories == undefined || resultDetails.allCategories.length === 0) return "";
90+
if (resultDetails.allCategories == null || resultDetails.allCategories.length === 0) return "";
9191

9292
return html ` ${algoliaConfig.translations.orIn}
9393
${resultDetails.allCategories.map((list, index) =>

0 commit comments

Comments
 (0)