From eda3b0a2f999be32ff443acadadada460ec39e49 Mon Sep 17 00:00:00 2001 From: Eric Wright Date: Thu, 20 Oct 2022 15:27:15 -0400 Subject: [PATCH 01/55] INTEG-351: Ignore VS code config --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6731d97ec..4abf887f0 100755 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ dev/bin/auth.json composer.lock vendor/ .php_cs.cache +.vscode From 383a3979e08a6aeb0a0837dc1bc419e0a319c620 Mon Sep 17 00:00:00 2001 From: Eric Wright Date: Sun, 23 Oct 2022 21:20:59 -0400 Subject: [PATCH 02/55] INTEG-355: Relabel variable for consistency with source API --- .../template/autocomplete/products.js | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/view/frontend/web/internals/template/autocomplete/products.js b/view/frontend/web/internals/template/autocomplete/products.js index 18ca3835b..f9a59c12a 100644 --- a/view/frontend/web/internals/template/autocomplete/products.js +++ b/view/frontend/web/internals/template/autocomplete/products.js @@ -1,48 +1,48 @@ define([], function () { return { - getProductsHtml: function (_data, components, html) { + getProductsHtml: function (item, components, html) { var color = ''; - if (_data._highlightResult.color !== undefined) { - color = _data._highlightResult.color.value; + if (item._highlightResult.color !== undefined) { + color = item._highlightResult.color.value; } var origFormatedVar = algoliaConfig.origFormatedVar; var tierFormatedvar = algoliaConfig.tierFormatedVar; if (algoliaConfig.priceGroup == null) { - return html` -
${_data.name || ''}
+ return html`
+
${item.name || ''}
- ${components.Highlight({hit: _data, attribute: 'name'}) || ''} + ${components.Highlight({hit: item, attribute: 'name'}) || ''}
- ${color && color != '' ? html `color : ${components.Highlight({hit: _data, attribute: 'color'})}` : - _data.categories_without_path && _data.categories_without_path.length != 0 ? html `in ${components.Highlight({hit: _data, attribute: 'categories_without_path'})}` : ''} + ${color && color != '' ? html `color : ${components.Highlight({hit: item, attribute: 'color'})}` : + item.categories_without_path && item.categories_without_path.length != 0 ? html `in ${components.Highlight({hit: item, attribute: 'categories_without_path'})}` : ''}
- ${_data['price'] !== undefined ? html `
+ ${item['price'] !== undefined ? html `
- ${_data['price'][algoliaConfig.currencyCode]['default_formated']} + ${item['price'][algoliaConfig.currencyCode]['default_formated']} - ${_data['price'][algoliaConfig.currencyCode]['default_original_formated'] != null ? html` - ${_data['price'][algoliaConfig.currencyCode]['default_original_formated']}` : ''} + ${item['price'][algoliaConfig.currencyCode]['default_original_formated'] != null ? html` + ${item['price'][algoliaConfig.currencyCode]['default_original_formated']}` : ''}
` : ''}
`; } else { - return html` -
${_data.name || ''}
+ return html`
+
${item.name || ''}
- ${components.Highlight({hit: _data, attribute: 'name'}) || ''} + ${components.Highlight({hit: item, attribute: 'name'}) || ''}
- ${color && color != '' ? html `color : ${components.Highlight({hit: _data, attribute: 'color'})}` : - _data.categories_without_path && _data.categories_without_path.length != 0 ? html `in ${components.Highlight({hit: _data, attribute: 'categories_without_path'})}` : ''} + ${color && color != '' ? html `color : ${components.Highlight({hit: item, attribute: 'color'})}` : + item.categories_without_path && item.categories_without_path.length != 0 ? html `in ${components.Highlight({hit: item, attribute: 'categories_without_path'})}` : ''}
- ${_data['price'] !== undefined ? html `
+ ${item['price'] !== undefined ? html `
- ${_data['price'][algoliaConfig.currencyCode][algoliaConfig.priceGroup + '_formated']} + ${item['price'][algoliaConfig.currencyCode][algoliaConfig.priceGroup + '_formated']} - ${_data['price'][algoliaConfig.currencyCode][algoliaConfig.priceGroup + '_original_formated'] != null ? html` - ${_data['price'][algoliaConfig.currencyCode][algoliaConfig.priceGroup + '_original_formated']}` : ''} + ${item['price'][algoliaConfig.currencyCode][algoliaConfig.priceGroup + '_original_formated'] != null ? html` + ${item['price'][algoliaConfig.currencyCode][algoliaConfig.priceGroup + '_original_formated']}` : ''} - ${_data['price'][algoliaConfig.currencyCode][algoliaConfig.priceGroup + '_tier_formated'] != null ? html` - As low as ${_data['price'][algoliaConfig.currencyCode][algoliaConfig.priceGroup + '_tier_formated']}` : ''} + ${item['price'][algoliaConfig.currencyCode][algoliaConfig.priceGroup + '_tier_formated'] != null ? html` + As low as ${item['price'][algoliaConfig.currencyCode][algoliaConfig.priceGroup + '_tier_formated']}` : ''}
` : ''}
`; From d4153923addb893c835f2fad380238f18f43513b Mon Sep 17 00:00:00 2001 From: Eric Wright Date: Sun, 23 Oct 2022 21:38:22 -0400 Subject: [PATCH 03/55] INTEG-355: Apply consistent naming convention for template methods --- view/frontend/web/autocomplete.js | 10 +++++----- .../template/autocomplete/additional-section.js | 2 +- .../web/internals/template/autocomplete/categories.js | 2 +- .../web/internals/template/autocomplete/pages.js | 2 +- .../web/internals/template/autocomplete/products.js | 2 +- .../web/internals/template/autocomplete/suggestions.js | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/view/frontend/web/autocomplete.js b/view/frontend/web/autocomplete.js index 527e6e105..6d4994e70 100755 --- a/view/frontend/web/autocomplete.js +++ b/view/frontend/web/autocomplete.js @@ -189,7 +189,7 @@ requirejs(['algoliaBundle', 'pagesHtml', 'categoriesHtml', 'productsHtml', 'sugg algoliaAutocomplete.$('.aa-PanelLayout').append(algoliaFooter); } var _data = transformAutocompleteHit(item, algoliaConfig.priceKey, $); - return productsHtml.getProductsHtml(_data, components, html); + return productsHtml.getItemHtml(_data, components, html); }, footer({html}) { var keys = []; @@ -248,7 +248,7 @@ requirejs(['algoliaBundle', 'pagesHtml', 'categoriesHtml', 'productsHtml', 'sugg return categoriesHtml.getHeaderHtml(section); }, item({ item, components, html }) { - return categoriesHtml.getCategoriesHtml(item, components, html); + return categoriesHtml.getItemHtml(item, components, html); } } }; @@ -268,7 +268,7 @@ requirejs(['algoliaBundle', 'pagesHtml', 'categoriesHtml', 'productsHtml', 'sugg return pagesHtml.getHeaderHtml(section); }, item({ item, components, html }) { - return pagesHtml.getPagesHtml(item, components, html); + return pagesHtml.getItemHtml(item, components, html); } } }; @@ -306,7 +306,7 @@ requirejs(['algoliaBundle', 'pagesHtml', 'categoriesHtml', 'productsHtml', 'sugg return additionalHtml.getHeaderHtml(section); }, item({ item, components, html }) { - return additionalHtml.getAdditionalHtml(item, components, html); + return additionalHtml.getItemHtml(item, components, html); } } }; @@ -413,7 +413,7 @@ requirejs(['algoliaBundle', 'pagesHtml', 'categoriesHtml', 'productsHtml', 'sugg }, item(params) { const { item, html } = params; - return suggestionsHtml.getSuggestionsHtml(item, html) + return suggestionsHtml.getItemHtml(item, html) }, }, }; diff --git a/view/frontend/web/internals/template/autocomplete/additional-section.js b/view/frontend/web/internals/template/autocomplete/additional-section.js index ed161b942..728e4baae 100644 --- a/view/frontend/web/internals/template/autocomplete/additional-section.js +++ b/view/frontend/web/internals/template/autocomplete/additional-section.js @@ -1,6 +1,6 @@ define([], function () { return { - getAdditionalHtml: function (item, components, html) { + getItemHtml: function (item, components, html) { return html`${components.Highlight({ hit: item, attribute: 'value' })}`; }, diff --git a/view/frontend/web/internals/template/autocomplete/categories.js b/view/frontend/web/internals/template/autocomplete/categories.js index 090beafd1..ca8e1f36c 100644 --- a/view/frontend/web/internals/template/autocomplete/categories.js +++ b/view/frontend/web/internals/template/autocomplete/categories.js @@ -1,6 +1,6 @@ define([], function () { return { - getCategoriesHtml: function (item, components, html) { + getItemHtml: function (item, components, html) { return html ` ${components.Highlight({ hit: item, attribute: 'path' })} (${item.product_count}) `; diff --git a/view/frontend/web/internals/template/autocomplete/pages.js b/view/frontend/web/internals/template/autocomplete/pages.js index 858059a80..62702fea9 100644 --- a/view/frontend/web/internals/template/autocomplete/pages.js +++ b/view/frontend/web/internals/template/autocomplete/pages.js @@ -1,6 +1,6 @@ define([], function () { return { - getPagesHtml: function (item, components, html) { + getItemHtml: function (item, components, html) { return html`
${components.Highlight({hit: item, attribute: 'name'})} diff --git a/view/frontend/web/internals/template/autocomplete/products.js b/view/frontend/web/internals/template/autocomplete/products.js index f9a59c12a..7db78597f 100644 --- a/view/frontend/web/internals/template/autocomplete/products.js +++ b/view/frontend/web/internals/template/autocomplete/products.js @@ -1,6 +1,6 @@ define([], function () { return { - getProductsHtml: function (item, components, html) { + getItemHtml: function (item, components, html) { var color = ''; if (item._highlightResult.color !== undefined) { color = item._highlightResult.color.value; diff --git a/view/frontend/web/internals/template/autocomplete/suggestions.js b/view/frontend/web/internals/template/autocomplete/suggestions.js index 3b1d86344..5e3c65ece 100644 --- a/view/frontend/web/internals/template/autocomplete/suggestions.js +++ b/view/frontend/web/internals/template/autocomplete/suggestions.js @@ -1,6 +1,6 @@ define([], function () { return { - getSuggestionsHtml: function (item, html) { + getItemHtml: function (item, html) { return html` ${item.query} `; From 9965d329352e917e257927187389644417df0d5d Mon Sep 17 00:00:00 2001 From: Eric Wright Date: Sun, 23 Oct 2022 23:27:27 -0400 Subject: [PATCH 04/55] INTEG-355: Begin to modularize template --- view/frontend/web/autocomplete.js | 6 +++++- view/frontend/web/internals/autocomplete.css | 4 ++++ .../template/autocomplete/products.js | 21 ++++++++++++------- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/view/frontend/web/autocomplete.js b/view/frontend/web/autocomplete.js index 6d4994e70..ec137579d 100755 --- a/view/frontend/web/autocomplete.js +++ b/view/frontend/web/autocomplete.js @@ -2,7 +2,11 @@ let algoliaAutocomplete; let suggestionSection = false; let algoliaFooter; let productResult = []; -requirejs(['algoliaBundle', 'pagesHtml', 'categoriesHtml', 'productsHtml', 'suggestionsHtml', 'additionalHtml', 'domReady!'], function(algoliaBundle, pagesHtml, categoriesHtml, productsHtml, suggestionsHtml, additionalHtml) { +requirejs( + ['jquery', 'algoliaBundle', 'pagesHtml', 'categoriesHtml', 'productsHtml', 'suggestionsHtml', 'additionalHtml', 'domReady!'], + function(jQuery, algoliaBundle, pagesHtml, categoriesHtml, productsHtml, suggestionsHtml, additionalHtml) + + { algoliaAutocomplete = algoliaBundle; algoliaBundle.$(function ($) { diff --git a/view/frontend/web/internals/autocomplete.css b/view/frontend/web/internals/autocomplete.css index fc7fb1926..d9dacfe3a 100755 --- a/view/frontend/web/internals/autocomplete.css +++ b/view/frontend/web/internals/autocomplete.css @@ -370,6 +370,10 @@ color: #222; } +.algoliasearch-autocomplete-hit .info .algoliasearch-autocomplete-category span:nth-child(n+2):before { + content: " | "; +} + #algolia-autocomplete-container .aa-dropdown-menu .footer_algolia { position: absolute; width: 100%; diff --git a/view/frontend/web/internals/template/autocomplete/products.js b/view/frontend/web/internals/template/autocomplete/products.js index 7db78597f..3bab9c9d7 100644 --- a/view/frontend/web/internals/template/autocomplete/products.js +++ b/view/frontend/web/internals/template/autocomplete/products.js @@ -1,20 +1,27 @@ define([], function () { return { + getColorHtml: (item, components, html) => { + return item._highlightResult.color !== undefined && item._highlightResult.color.value !== '' + ? html`color: ${components.Highlight({ hit: item, attribute: "color" })}` + : ""; + }, + getCategoriesHtml: (item, components, html) => { + return item.categories_without_path && + item.categories_without_path.length + ? html`in ${components.Highlight({ hit: item, attribute: "categories_without_path",})}` + : ""; + }, getItemHtml: function (item, components, html) { - var color = ''; - if (item._highlightResult.color !== undefined) { - color = item._highlightResult.color.value; - } var origFormatedVar = algoliaConfig.origFormatedVar; var tierFormatedvar = algoliaConfig.tierFormatedVar; if (algoliaConfig.priceGroup == null) { return html`
${item.name || ''}
- ${components.Highlight({hit: item, attribute: 'name'}) || ''} + ${components.Highlight({hit: item, attribute: 'name'})}
- ${color && color != '' ? html `color : ${components.Highlight({hit: item, attribute: 'color'})}` : - item.categories_without_path && item.categories_without_path.length != 0 ? html `in ${components.Highlight({hit: item, attribute: 'categories_without_path'})}` : ''} + ${this.getColorHtml(item, components, html)} + ${this.getCategoriesHtml(item, components, html)}
${item['price'] !== undefined ? html `
From 7deed64302c5f3ae47d5a0b21b0921f7e6704e05 Mon Sep 17 00:00:00 2001 From: Eric Wright Date: Sun, 23 Oct 2022 23:45:22 -0400 Subject: [PATCH 05/55] INTEG-355: Switch ternary to guard clause --- .../internals/template/autocomplete/products.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/view/frontend/web/internals/template/autocomplete/products.js b/view/frontend/web/internals/template/autocomplete/products.js index 3bab9c9d7..7d47fdfec 100644 --- a/view/frontend/web/internals/template/autocomplete/products.js +++ b/view/frontend/web/internals/template/autocomplete/products.js @@ -1,16 +1,18 @@ define([], function () { return { + getColorHtml: (item, components, html) => { - return item._highlightResult.color !== undefined && item._highlightResult.color.value !== '' - ? html`color: ${components.Highlight({ hit: item, attribute: "color" })}` - : ""; + if (item._highlightResult.color == undefined || item._highlightResult.color.value == "") return ""; + + return html`color: ${components.Highlight({ hit: item, attribute: "color" })}`; }, + getCategoriesHtml: (item, components, html) => { - return item.categories_without_path && - item.categories_without_path.length - ? html`in ${components.Highlight({ hit: item, attribute: "categories_without_path",})}` - : ""; + if (item.categories_without_path == undefined || item.categories_without_path.length == 0) return ""; + + return html`in ${components.Highlight({ hit: item, attribute: "categories_without_path",})}`; }, + getItemHtml: function (item, components, html) { var origFormatedVar = algoliaConfig.origFormatedVar; var tierFormatedvar = algoliaConfig.tierFormatedVar; From 9d4bb4c6aa8f9f66423313d5f59cab4b2f6843a1 Mon Sep 17 00:00:00 2001 From: Eric Wright Date: Mon, 24 Oct 2022 01:45:13 -0400 Subject: [PATCH 06/55] INTEG-355: Refactor pricing logic --- view/frontend/web/internals/autocomplete.css | 9 +++ .../template/autocomplete/products.js | 79 +++++++++---------- 2 files changed, 47 insertions(+), 41 deletions(-) diff --git a/view/frontend/web/internals/autocomplete.css b/view/frontend/web/internals/autocomplete.css index d9dacfe3a..23ffbfc92 100755 --- a/view/frontend/web/internals/autocomplete.css +++ b/view/frontend/web/internals/autocomplete.css @@ -374,6 +374,15 @@ content: " | "; } +.algoliasearch-autocomplete-hit .info .algoliasearch-autocomplete-price .after_special:after { + content: " "; +} + +.algoliasearch-autocomplete-hit .info .algoliasearch-autocomplete-price .tier_price { + padding-left: 5px; +} + + #algolia-autocomplete-container .aa-dropdown-menu .footer_algolia { position: absolute; width: 100%; diff --git a/view/frontend/web/internals/template/autocomplete/products.js b/view/frontend/web/internals/template/autocomplete/products.js index 7d47fdfec..077d4746b 100644 --- a/view/frontend/web/internals/template/autocomplete/products.js +++ b/view/frontend/web/internals/template/autocomplete/products.js @@ -13,49 +13,46 @@ define([], function () { return html`in ${components.Highlight({ hit: item, attribute: "categories_without_path",})}`; }, + getOriginalPriceHtml: (item, html, priceGroup) => { + if (item['price'][algoliaConfig.currencyCode][priceGroup + '_original_formated'] == null) return ""; + + return html` ${item['price'][algoliaConfig.currencyCode][priceGroup + '_original_formated']} `; + }, + + getTierPriceHtml: (item, html, priceGroup) => { + if (item['price'][algoliaConfig.currencyCode][priceGroup + '_tier_formated'] == null) return ""; + + return html` As low as ${item['price'][algoliaConfig.currencyCode][priceGroup + '_tier_formated']}`; + }, + + getPricingHtml: function(item, html) { + if (item['price'] == undefined) return ""; + + const priceGroup = algoliaConfig.priceGroup || 'default'; + + return html `
+ + ${item['price'][algoliaConfig.currencyCode][priceGroup + '_formated']} + + ${this.getOriginalPriceHtml(item, html, priceGroup)} + + ${this.getTierPriceHtml(item, html, priceGroup)} +
`; + }, + getItemHtml: function (item, components, html) { - var origFormatedVar = algoliaConfig.origFormatedVar; - var tierFormatedvar = algoliaConfig.tierFormatedVar; - if (algoliaConfig.priceGroup == null) { - return html`
-
${item.name || ''}
-
- ${components.Highlight({hit: item, attribute: 'name'})} -
- ${this.getColorHtml(item, components, html)} - ${this.getCategoriesHtml(item, components, html)} -
- ${item['price'] !== undefined ? html `
- - ${item['price'][algoliaConfig.currencyCode]['default_formated']} - - ${item['price'][algoliaConfig.currencyCode]['default_original_formated'] != null ? html` - ${item['price'][algoliaConfig.currencyCode]['default_original_formated']}` : ''} -
` : ''} + return html`
+
${item.name || ''}
+
+ `; }, getHeaderHtml: function (section) { From e825942b49ed25b174247f5c4bf9d68078f1efb5 Mon Sep 17 00:00:00 2001 From: Eric Wright Date: Mon, 24 Oct 2022 05:42:22 -0400 Subject: [PATCH 07/55] INTEG-355: Refactor to eliminate dependency on global variables and eliminate conditionals in function templates --- view/frontend/web/autocomplete.js | 70 +++++++++---------- .../template/autocomplete/products.js | 32 ++++++--- 2 files changed, 56 insertions(+), 46 deletions(-) diff --git a/view/frontend/web/autocomplete.js b/view/frontend/web/autocomplete.js index ec137579d..e06a5a79a 100755 --- a/view/frontend/web/autocomplete.js +++ b/view/frontend/web/autocomplete.js @@ -1,7 +1,6 @@ let algoliaAutocomplete; let suggestionSection = false; let algoliaFooter; -let productResult = []; requirejs( ['jquery', 'algoliaBundle', 'pagesHtml', 'categoriesHtml', 'productsHtml', 'suggestionsHtml', 'additionalHtml', 'domReady!'], function(jQuery, algoliaBundle, pagesHtml, categoriesHtml, productsHtml, suggestionsHtml, additionalHtml) @@ -195,41 +194,30 @@ requirejs( var _data = transformAutocompleteHit(item, algoliaConfig.priceKey, $); return productsHtml.getItemHtml(_data, components, html); }, - footer({html}) { - var keys = []; - for (var i = 0; i { + const url = resultDetails.allDepartmentsUrl + '&categories=' + encodeURIComponent(key); + return { + name: key, + value: firstItem.allCategories[key], + url + }; + }); + //reverse value sort apparently... + allCategories.sort((a, b) => b.value - a.value); + resultDetails.allCategories = allCategories.slice(0, 2); } } - - keys.sort(function (a, b) { - return b.value - a.value; - }); - - var orsTab = []; - - if (keys.length > 0) { - orsTab = []; - for (var i = 0; i < keys.length && i < 2; i++) { - orsTab.push( - { - url:keys[i].url, - name:keys[i].key - } - ); - } - } - - var allUrl = algoliaConfig.baseUrl + '/catalogsearch/result/?q=' + encodeURIComponent(productResult[0].query); - return productsHtml.getFooterHtml(html, orsTab, allUrl, productResult) + + return productsHtml.getFooterHtml(html, resultDetails); } } }; @@ -437,8 +425,18 @@ requirejs( }, ], transformResponse({ results, hits }) { - productResult = results; - return hits; + const resDetail = results[0]; + + return hits.map(res => { + return res.map(hit => { + return { + ...hit, + nbHits: resDetail.nbHits, + allCategories: resDetail.facets['categories.level0'], + query: resDetail.query + } + }) + }); }, }); }, diff --git a/view/frontend/web/internals/template/autocomplete/products.js b/view/frontend/web/internals/template/autocomplete/products.js index 077d4746b..c58193cfd 100644 --- a/view/frontend/web/internals/template/autocomplete/products.js +++ b/view/frontend/web/internals/template/autocomplete/products.js @@ -63,16 +63,28 @@ define([], function () { return 'No Results'; }, - getFooterHtml: function (html, orsTab, allUrl, productResult) { - if(orsTab && orsTab.length > 0 && algoliaConfig.instant.enabled) { - return html ``; - }else{ - return html ``; - } + getFooterSearchCategoryLinks: (html, resultDetails) => { + if (resultDetails.allCategories == undefined) return ""; + + return html ` ${algoliaConfig.translations.orIn} + ${resultDetails.allCategories.map((list, index) => + index === 0 ? html` ${list.name}` : html`, ${list.name}` + )} + `; + }, + + getFooterSearchLinks: function(html, resultDetails) { + if (resultDetails.nbHits === 0) return ""; + + return html`${algoliaConfig.translations.seeIn} ${algoliaConfig.translations.allDepartments} (${resultDetails.nbHits}) + ${this.getFooterSearchCategoryLinks(html, resultDetails)} + `; + }, + + getFooterHtml: function (html, resultDetails) { + return html``; } }; }); From ffe184d42ee928fb7a78a8638d2fc8a40f9fd678 Mon Sep 17 00:00:00 2001 From: Eric Wright Date: Mon, 24 Oct 2022 06:34:27 -0400 Subject: [PATCH 08/55] INTEG-355: Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2bfab2f60..bed1b8c62 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Algolia Search integration for Magento 2", "type": "magento2-module", "license": ["MIT"], - "version": "3.8.1", + "version": "3.9.0", "require": { "magento/framework": "~102.0|~103.0", "algolia/algoliasearch-client-php": "3.2", From 5716ebd8913fd7ce8c37e45ee4592b86f0d6966f Mon Sep 17 00:00:00 2001 From: Eric Wright Date: Mon, 24 Oct 2022 21:26:56 -0400 Subject: [PATCH 09/55] INTEG-355: Convert autocomplete.js to AMD --- .../frontend/layout/algolia_search_handle.xml | 2 +- view/frontend/requirejs-config.js | 24 +++++++++++++------ view/frontend/web/autocomplete.js | 6 ++--- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/view/frontend/layout/algolia_search_handle.xml b/view/frontend/layout/algolia_search_handle.xml index d41bc1e73..45b790e1b 100755 --- a/view/frontend/layout/algolia_search_handle.xml +++ b/view/frontend/layout/algolia_search_handle.xml @@ -4,7 +4,7 @@ - + diff --git a/view/frontend/web/recommend.js b/view/frontend/web/recommend.js index 7c32e4e23..73fbe55ff 100644 --- a/view/frontend/web/recommend.js +++ b/view/frontend/web/recommend.js @@ -119,11 +119,13 @@ requirejs([ {className: "recommend-item product-url", href: item.url, 'data-objectId': item.objectID, 'data-index': this.defaultIndexName}, createElement('img', {className: "product-img", src: item.image_url}, item.image_url), createElement('p', {className: "product-name"}, item.name), - createElement('form', {className: 'addTocartForm', action: action, method: 'post'}, + createElement('form', {id: 'product_addtocart_form', className: 'addTocartForm', action: action, method: 'post', 'data-role':'tocart-form'}, createElement('input', {type: 'hidden', name: 'form_key',value: config.recommend.addToCartParams.formKey}), createElement('input', {type: 'hidden', name:'unec', value: AlgoliaBase64.mageEncode(action)}), createElement('input', {type: 'hidden', name:'product', value: item.objectID}), - createElement('button', {type: 'submit', className: 'action tocart primary'}, $tr('Add To Cart')) + createElement('button', {type: 'submit', className: 'action tocart primary'}, [ + createElement('span', {}, $tr('Add To Cart')) + ]) ) ) ) From 2f31e1286f4e58a92afc167624153a14bd9134aa Mon Sep 17 00:00:00 2001 From: Ratikant Singh Date: Tue, 1 Nov 2022 15:25:39 +0530 Subject: [PATCH 28/55] autocomplete css issue fix --- view/frontend/web/internals/autocomplete.css | 10 ++++++++-- view/frontend/web/internals/common.js | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/view/frontend/web/internals/autocomplete.css b/view/frontend/web/internals/autocomplete.css index 7f741e0de..c08358b8a 100755 --- a/view/frontend/web/internals/autocomplete.css +++ b/view/frontend/web/internals/autocomplete.css @@ -527,7 +527,7 @@ html { } .footer_algolia .algolia-search-by-label { - color: var(--autocomplete-muted-color); + color: var(--autocomplete-muted-color); font-size: .9em; margin-right: 5px; } @@ -598,7 +598,13 @@ html { } @media (max-width: 768px) { - .aa-Panel .aa-PanelLayout, .footer_algolia{ + .aa-Panel .aa-PanelLayout { + justify-content: start; + width:100%; + display: flex; + flex-direction: column; + } + .footer_algolia{ width: 100%; justify-content: center; } diff --git a/view/frontend/web/internals/common.js b/view/frontend/web/internals/common.js index 4c7f7fb86..a965695af 100755 --- a/view/frontend/web/internals/common.js +++ b/view/frontend/web/internals/common.js @@ -323,7 +323,7 @@ requirejs(['algoliaBundle'], function(algoliaBundle) { return protocol + '//' + hostname + portWithPrefix + pathname; } else { - if (queryString) { + if (queryString && queryString != 'q=__empty__') { return protocol + '//' + hostname + portWithPrefix + pathname + '?' + queryString; } else { return protocol + '//' + hostname + portWithPrefix + pathname; From b0cc4825992f36ccf6e46a02d1e0f6a027c7d556 Mon Sep 17 00:00:00 2001 From: Ratikant Singh Date: Tue, 1 Nov 2022 19:12:08 +0530 Subject: [PATCH 29/55] Click event fix for autcomplete --- view/frontend/web/autocomplete.js | 13 ++++--------- .../template/autocomplete/additional-section.js | 3 ++- .../internals/template/autocomplete/categories.js | 3 ++- .../web/internals/template/autocomplete/pages.js | 3 ++- .../web/internals/template/autocomplete/products.js | 3 ++- .../internals/template/autocomplete/suggestions.js | 3 ++- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/view/frontend/web/autocomplete.js b/view/frontend/web/autocomplete.js index 6362403b4..d3706a5a7 100755 --- a/view/frontend/web/autocomplete.js +++ b/view/frontend/web/autocomplete.js @@ -504,9 +504,11 @@ define( const $this = $(this); if ($this.data('clicked')) return; - let itemUrl = $this.attr('href'); + let objectId = $this.attr('objectId'); + let indexName = $this.attr('indexName'); + let queryId = $this.attr('queryId'); let eventData = algoliaInsights.buildEventData( - 'Clicked', getHitsUrlParameter(itemUrl, 'objectID'), getHitsUrlParameter(itemUrl, 'indexName'), 1, getHitsUrlParameter(itemUrl, 'queryID') + 'Clicked', objectId, indexName, 1, queryId ); algoliaInsights.trackClick(eventData); $this.attr('data-clicked', true); @@ -514,11 +516,4 @@ define( } }); }); - - function getHitsUrlParameter(url, name) { - name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); - const regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), - results = regex.exec(url); - return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); - } }); diff --git a/view/frontend/web/internals/template/autocomplete/additional-section.js b/view/frontend/web/internals/template/autocomplete/additional-section.js index df7059af4..2e480a6b4 100644 --- a/view/frontend/web/internals/template/autocomplete/additional-section.js +++ b/view/frontend/web/internals/template/autocomplete/additional-section.js @@ -9,7 +9,8 @@ define([], function () { }, getItemHtml: function ({item, components, html, section}) { - return html` + return html` ${components.Highlight({ hit: item, attribute: 'value' })} `; diff --git a/view/frontend/web/internals/template/autocomplete/categories.js b/view/frontend/web/internals/template/autocomplete/categories.js index e8ef3bd20..55af41316 100644 --- a/view/frontend/web/internals/template/autocomplete/categories.js +++ b/view/frontend/web/internals/template/autocomplete/categories.js @@ -9,7 +9,8 @@ define([], function () { }, getItemHtml: function ({item, components, html}) { - return html ` + return html ` ${components.Highlight({ hit: item, attribute: 'path' })} (${item.product_count}) `; }, diff --git a/view/frontend/web/internals/template/autocomplete/pages.js b/view/frontend/web/internals/template/autocomplete/pages.js index 2ad7d47a1..067b6637c 100644 --- a/view/frontend/web/internals/template/autocomplete/pages.js +++ b/view/frontend/web/internals/template/autocomplete/pages.js @@ -9,7 +9,8 @@ define([], function () { }, getItemHtml: function ({item, components, html}) { - return html` + return html`
${components.Highlight({hit: item, attribute: 'name'})}
diff --git a/view/frontend/web/internals/template/autocomplete/products.js b/view/frontend/web/internals/template/autocomplete/products.js index 372285ff8..77c425060 100644 --- a/view/frontend/web/internals/template/autocomplete/products.js +++ b/view/frontend/web/internals/template/autocomplete/products.js @@ -14,7 +14,8 @@ define([], function () { }, getItemHtml: function ({item, components, html}) { - return html` + return html`
${item.name || ''}
${components.Highlight({hit: item, attribute: 'name'})} diff --git a/view/frontend/web/internals/template/autocomplete/suggestions.js b/view/frontend/web/internals/template/autocomplete/suggestions.js index b6137e2d8..8707399c6 100644 --- a/view/frontend/web/internals/template/autocomplete/suggestions.js +++ b/view/frontend/web/internals/template/autocomplete/suggestions.js @@ -9,7 +9,8 @@ define([], function () { }, getItemHtml: function ({item, html}) { - return html` + return html` ${item.query} `; }, From e4fe74548398551042b509e6d0680d815c5da043 Mon Sep 17 00:00:00 2001 From: Ratikant Singh Date: Tue, 1 Nov 2022 19:59:13 +0530 Subject: [PATCH 30/55] Removed extra id --- view/frontend/web/recommend.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/frontend/web/recommend.js b/view/frontend/web/recommend.js index 73fbe55ff..4921e54f4 100644 --- a/view/frontend/web/recommend.js +++ b/view/frontend/web/recommend.js @@ -119,7 +119,7 @@ requirejs([ {className: "recommend-item product-url", href: item.url, 'data-objectId': item.objectID, 'data-index': this.defaultIndexName}, createElement('img', {className: "product-img", src: item.image_url}, item.image_url), createElement('p', {className: "product-name"}, item.name), - createElement('form', {id: 'product_addtocart_form', className: 'addTocartForm', action: action, method: 'post', 'data-role':'tocart-form'}, + createElement('form', {className: 'addTocartForm', action: action, method: 'post', 'data-role':'tocart-form'}, createElement('input', {type: 'hidden', name: 'form_key',value: config.recommend.addToCartParams.formKey}), createElement('input', {type: 'hidden', name:'unec', value: AlgoliaBase64.mageEncode(action)}), createElement('input', {type: 'hidden', name:'product', value: item.objectID}), From 0f9671f6d606bba21d04b82ea29736802429eb2b Mon Sep 17 00:00:00 2001 From: Ratikant Singh Date: Wed, 2 Nov 2022 12:18:46 +0530 Subject: [PATCH 31/55] resolve comment --- view/frontend/web/autocomplete.js | 6 +++--- .../internals/template/autocomplete/additional-section.js | 2 +- .../web/internals/template/autocomplete/categories.js | 2 +- view/frontend/web/internals/template/autocomplete/pages.js | 2 +- .../web/internals/template/autocomplete/products.js | 2 +- .../web/internals/template/autocomplete/suggestions.js | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/view/frontend/web/autocomplete.js b/view/frontend/web/autocomplete.js index d3706a5a7..79a497ee4 100755 --- a/view/frontend/web/autocomplete.js +++ b/view/frontend/web/autocomplete.js @@ -504,9 +504,9 @@ define( const $this = $(this); if ($this.data('clicked')) return; - let objectId = $this.attr('objectId'); - let indexName = $this.attr('indexName'); - let queryId = $this.attr('queryId'); + let objectId = $this.attr('data-object-id'); + let indexName = $this.attr('data-index-name'); + let queryId = $this.attr('data-query-id'); let eventData = algoliaInsights.buildEventData( 'Clicked', objectId, indexName, 1, queryId ); diff --git a/view/frontend/web/internals/template/autocomplete/additional-section.js b/view/frontend/web/internals/template/autocomplete/additional-section.js index 2e480a6b4..11973376d 100644 --- a/view/frontend/web/internals/template/autocomplete/additional-section.js +++ b/view/frontend/web/internals/template/autocomplete/additional-section.js @@ -10,7 +10,7 @@ define([], function () { getItemHtml: function ({item, components, html, section}) { return html` + data-object-id=${item.objectID} data-index-name=${item.__autocomplete_indexName} data-query-id=${item.__autocomplete_queryID}> ${components.Highlight({ hit: item, attribute: 'value' })} `; diff --git a/view/frontend/web/internals/template/autocomplete/categories.js b/view/frontend/web/internals/template/autocomplete/categories.js index 55af41316..41d9e2bdb 100644 --- a/view/frontend/web/internals/template/autocomplete/categories.js +++ b/view/frontend/web/internals/template/autocomplete/categories.js @@ -10,7 +10,7 @@ define([], function () { getItemHtml: function ({item, components, html}) { return html ` + data-object-id=${item.objectID} data-index-name=${item.__autocomplete_indexName} data-query-id=${item.__autocomplete_queryID}> ${components.Highlight({ hit: item, attribute: 'path' })} (${item.product_count}) `; }, diff --git a/view/frontend/web/internals/template/autocomplete/pages.js b/view/frontend/web/internals/template/autocomplete/pages.js index 067b6637c..8a888e613 100644 --- a/view/frontend/web/internals/template/autocomplete/pages.js +++ b/view/frontend/web/internals/template/autocomplete/pages.js @@ -10,7 +10,7 @@ define([], function () { getItemHtml: function ({item, components, html}) { return html` + data-object-id=${item.objectID} data-index-name=${item.__autocomplete_indexName} data-query-id=${item.__autocomplete_queryID}>
${components.Highlight({hit: item, attribute: 'name'})}
diff --git a/view/frontend/web/internals/template/autocomplete/products.js b/view/frontend/web/internals/template/autocomplete/products.js index 77c425060..5fc435ba6 100644 --- a/view/frontend/web/internals/template/autocomplete/products.js +++ b/view/frontend/web/internals/template/autocomplete/products.js @@ -15,7 +15,7 @@ define([], function () { getItemHtml: function ({item, components, html}) { return html` + data-object-id=${item.objectID} data-index-name=${item.__autocomplete_indexName} data-query-id=${item.__autocomplete_queryID}>
${item.name || ''}
${components.Highlight({hit: item, attribute: 'name'})} diff --git a/view/frontend/web/internals/template/autocomplete/suggestions.js b/view/frontend/web/internals/template/autocomplete/suggestions.js index 8707399c6..2384556aa 100644 --- a/view/frontend/web/internals/template/autocomplete/suggestions.js +++ b/view/frontend/web/internals/template/autocomplete/suggestions.js @@ -10,7 +10,7 @@ define([], function () { getItemHtml: function ({item, html}) { return html` + data-object-id=${item.objectID} data-index-name=${item.__autocomplete_indexName} data-query-id=${item.__autocomplete_queryID}> ${item.query} `; }, From 7d242d4c9b2676ade15bd52f91eb6a28c27f74ac Mon Sep 17 00:00:00 2001 From: Ratikant Singh Date: Thu, 3 Nov 2022 14:57:34 +0530 Subject: [PATCH 32/55] personalization events fix for autocomplete --- view/frontend/web/autocomplete.js | 17 +++++------------ .../template/autocomplete/additional-section.js | 2 +- .../template/autocomplete/categories.js | 2 +- .../internals/template/autocomplete/pages.js | 2 +- .../internals/template/autocomplete/products.js | 2 +- .../template/autocomplete/suggestions.js | 2 +- 6 files changed, 10 insertions(+), 17 deletions(-) diff --git a/view/frontend/web/autocomplete.js b/view/frontend/web/autocomplete.js index 79a497ee4..484d71280 100755 --- a/view/frontend/web/autocomplete.js +++ b/view/frontend/web/autocomplete.js @@ -275,19 +275,12 @@ define( else if (section.name === "suggestions") { const suggestions_index = algolia_client.initIndex(algoliaConfig.indexName + "_suggestions"); - const products_index = algolia_client.initIndex(algoliaConfig.indexName + "_products"); // unused variable? - source = { displayKey: 'query', name: section.name, hitsPerPage: section.hitsPerPage, paramName: suggestions_index, - options, - templates: { - item({ item, html }) { - return html`
Suggestion List
`; - } - } + options }; } else { /** If is not products, categories, pages or suggestions, it's additional section **/ @@ -407,7 +400,7 @@ define( return { ...source, getItemUrl({ item }) { - return `/search?q=${item.query}`; + return `/catalogsearch/result/?q=${item.query}`; }, templates: { noResults({html}) { @@ -504,9 +497,9 @@ define( const $this = $(this); if ($this.data('clicked')) return; - let objectId = $this.attr('data-object-id'); - let indexName = $this.attr('data-index-name'); - let queryId = $this.attr('data-query-id'); + let objectId = $this.attr('data-objectId'); + let indexName = $this.attr('data-index'); + let queryId = $this.attr('data-queryId'); let eventData = algoliaInsights.buildEventData( 'Clicked', objectId, indexName, 1, queryId ); diff --git a/view/frontend/web/internals/template/autocomplete/additional-section.js b/view/frontend/web/internals/template/autocomplete/additional-section.js index 11973376d..2d581543e 100644 --- a/view/frontend/web/internals/template/autocomplete/additional-section.js +++ b/view/frontend/web/internals/template/autocomplete/additional-section.js @@ -10,7 +10,7 @@ define([], function () { getItemHtml: function ({item, components, html, section}) { return html` + data-objectId=${item.objectID} data-index=${item.__autocomplete_indexName} data-queryId=${item.__autocomplete_queryID}> ${components.Highlight({ hit: item, attribute: 'value' })} `; diff --git a/view/frontend/web/internals/template/autocomplete/categories.js b/view/frontend/web/internals/template/autocomplete/categories.js index 41d9e2bdb..7806ab35f 100644 --- a/view/frontend/web/internals/template/autocomplete/categories.js +++ b/view/frontend/web/internals/template/autocomplete/categories.js @@ -10,7 +10,7 @@ define([], function () { getItemHtml: function ({item, components, html}) { return html ` + data-objectId=${item.objectID} data-index=${item.__autocomplete_indexName} data-queryId=${item.__autocomplete_queryID}> ${components.Highlight({ hit: item, attribute: 'path' })} (${item.product_count}) `; }, diff --git a/view/frontend/web/internals/template/autocomplete/pages.js b/view/frontend/web/internals/template/autocomplete/pages.js index 8a888e613..b63e05047 100644 --- a/view/frontend/web/internals/template/autocomplete/pages.js +++ b/view/frontend/web/internals/template/autocomplete/pages.js @@ -10,7 +10,7 @@ define([], function () { getItemHtml: function ({item, components, html}) { return html` + data-objectId=${item.objectID} data-index=${item.__autocomplete_indexName} data-queryId=${item.__autocomplete_queryID}>
${components.Highlight({hit: item, attribute: 'name'})}
diff --git a/view/frontend/web/internals/template/autocomplete/products.js b/view/frontend/web/internals/template/autocomplete/products.js index 5fc435ba6..e673d10ee 100644 --- a/view/frontend/web/internals/template/autocomplete/products.js +++ b/view/frontend/web/internals/template/autocomplete/products.js @@ -15,7 +15,7 @@ define([], function () { getItemHtml: function ({item, components, html}) { return html` + data-objectId=${item.objectID} data-index=${item.__autocomplete_indexName} data-queryId=${item.__autocomplete_queryID}>
${item.name || ''}
${components.Highlight({hit: item, attribute: 'name'})} diff --git a/view/frontend/web/internals/template/autocomplete/suggestions.js b/view/frontend/web/internals/template/autocomplete/suggestions.js index 2384556aa..1cebfd07e 100644 --- a/view/frontend/web/internals/template/autocomplete/suggestions.js +++ b/view/frontend/web/internals/template/autocomplete/suggestions.js @@ -10,7 +10,7 @@ define([], function () { getItemHtml: function ({item, html}) { return html` + data-objectId=${item.objectID} data-index=${item.__autocomplete_indexName} data-queryId=${item.__autocomplete_queryID}> ${item.query} `; }, From fbe67e9fbd378f4050dd52d40a116a09a2584fce Mon Sep 17 00:00:00 2001 From: Ratikant Singh Date: Thu, 3 Nov 2022 17:43:17 +0530 Subject: [PATCH 33/55] instant search loading issue when price is not retrievable --- view/frontend/web/internals/common.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/view/frontend/web/internals/common.js b/view/frontend/web/internals/common.js index 542f646f1..d841e7d08 100755 --- a/view/frontend/web/internals/common.js +++ b/view/frontend/web/internals/common.js @@ -142,20 +142,20 @@ requirejs(['algoliaBundle'], function(algoliaBundle) { if (Array.isArray(hit._highlightResult.name)) hit._highlightResult.name = hit._highlightResult.name[0]; - if (Array.isArray(hit.price)) + if (Array.isArray(hit.price)) { hit.price = hit.price[0]; + if (hit['price'] !== undefined && price_key !== '.' + algoliaConfig.currencyCode + '.default' && hit['price'][algoliaConfig.currencyCode][price_key.substr(1) + '_formated'] !== hit['price'][algoliaConfig.currencyCode]['default_formated']) { + hit['price'][algoliaConfig.currencyCode][price_key.substr(1) + '_original_formated'] = hit['price'][algoliaConfig.currencyCode]['default_formated']; + } - if (hit['price'] !== undefined && price_key !== '.' + algoliaConfig.currencyCode + '.default' && hit['price'][algoliaConfig.currencyCode][price_key.substr(1) + '_formated'] !== hit['price'][algoliaConfig.currencyCode]['default_formated']) { - hit['price'][algoliaConfig.currencyCode][price_key.substr(1) + '_original_formated'] = hit['price'][algoliaConfig.currencyCode]['default_formated']; - } - - if (hit['price'][algoliaConfig.currencyCode]['default_original_formated'] - && hit['price'][algoliaConfig.currencyCode]['special_to_date']) { - var priceExpiration = hit['price'][algoliaConfig.currencyCode]['special_to_date']; + if (hit['price'][algoliaConfig.currencyCode]['default_original_formated'] + && hit['price'][algoliaConfig.currencyCode]['special_to_date']) { + var priceExpiration = hit['price'][algoliaConfig.currencyCode]['special_to_date']; - if (algoliaConfig.now > priceExpiration + 1) { - hit['price'][algoliaConfig.currencyCode]['default_formated'] = hit['price'][algoliaConfig.currencyCode]['default_original_formated']; - hit['price'][algoliaConfig.currencyCode]['default_original_formated'] = false; + if (algoliaConfig.now > priceExpiration + 1) { + hit['price'][algoliaConfig.currencyCode]['default_formated'] = hit['price'][algoliaConfig.currencyCode]['default_original_formated']; + hit['price'][algoliaConfig.currencyCode]['default_original_formated'] = false; + } } } From bc954dd0313b5780108c0a5b5cf78e69e0c11720 Mon Sep 17 00:00:00 2001 From: Ratikant Singh Date: Mon, 7 Nov 2022 17:14:50 +0530 Subject: [PATCH 34/55] catalogsearch result dynamic url --- Block/Configuration.php | 1 + view/frontend/web/autocomplete.js | 6 +++--- .../internals/template/autocomplete/additional-section.js | 2 +- .../web/internals/template/autocomplete/suggestions.js | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Block/Configuration.php b/Block/Configuration.php index 42bfb7124..e51e70bdb 100755 --- a/Block/Configuration.php +++ b/Block/Configuration.php @@ -213,6 +213,7 @@ public function getConfiguration() 'priceFormat' => $priceFormat, 'maxValuesPerFacet' => (int) $config->getMaxValuesPerFacet(), 'autofocus' => true, + 'resultPageUrl' => $this->getCatalogSearchHelper()->getResultUrl(), 'request' => [ 'query' => html_entity_decode($query), 'refinementKey' => $refinementKey, diff --git a/view/frontend/web/autocomplete.js b/view/frontend/web/autocomplete.js index 484d71280..1478dbdf7 100755 --- a/view/frontend/web/autocomplete.js +++ b/view/frontend/web/autocomplete.js @@ -198,7 +198,7 @@ define( const resultDetails = {}; if (items.length) { const firstItem = items[0]; - resultDetails.allDepartmentsUrl = algoliaConfig.baseUrl + '/catalogsearch/result/?q=' + encodeURIComponent(firstItem.query); + resultDetails.allDepartmentsUrl = algoliaConfig.resultPageUrl + '?q=' + encodeURIComponent(firstItem.query); resultDetails.nbHits = firstItem.nbHits; if (algoliaConfig.facets.find(facet => facet.attribute === 'categories')) { @@ -340,7 +340,7 @@ define( detachedMediaQuery: 'none', onSubmit(data){ if(data.state.query && data.state.query !== null && data.state.query !== ""){ - window.location.href = `/catalogsearch/result/?q=${data.state.query}`; + window.location.href = algoliaConfig.resultPageUrl+`?q=${data.state.query}`; } }, getSources() { @@ -400,7 +400,7 @@ define( return { ...source, getItemUrl({ item }) { - return `/catalogsearch/result/?q=${item.query}`; + return algoliaConfig.resultPageUrl+`?q=${item.query}`; }, templates: { noResults({html}) { diff --git a/view/frontend/web/internals/template/autocomplete/additional-section.js b/view/frontend/web/internals/template/autocomplete/additional-section.js index 2d581543e..354c9f2d7 100644 --- a/view/frontend/web/internals/template/autocomplete/additional-section.js +++ b/view/frontend/web/internals/template/autocomplete/additional-section.js @@ -9,7 +9,7 @@ define([], function () { }, getItemHtml: function ({item, components, html, section}) { - return html` ${components.Highlight({ hit: item, attribute: 'value' })} `; diff --git a/view/frontend/web/internals/template/autocomplete/suggestions.js b/view/frontend/web/internals/template/autocomplete/suggestions.js index 1cebfd07e..496bd5b27 100644 --- a/view/frontend/web/internals/template/autocomplete/suggestions.js +++ b/view/frontend/web/internals/template/autocomplete/suggestions.js @@ -9,7 +9,7 @@ define([], function () { }, getItemHtml: function ({item, html}) { - return html` ${item.query} `; From 0e8712605309fb79041612d36224afbf615d33ae Mon Sep 17 00:00:00 2001 From: Ratikant Singh Date: Mon, 7 Nov 2022 21:56:26 +0530 Subject: [PATCH 35/55] trending item click and add to cart fix --- .../templates/recommend/widget/trends-item.phtml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/view/frontend/templates/recommend/widget/trends-item.phtml b/view/frontend/templates/recommend/widget/trends-item.phtml index d15f6c577..f2750e593 100644 --- a/view/frontend/templates/recommend/widget/trends-item.phtml +++ b/view/frontend/templates/recommend/widget/trends-item.phtml @@ -5,7 +5,7 @@ */ $trendConstainer = 'trendItems' . $block->generateUniqueToken(); ?> -
+
\ No newline at end of file + + From 7d89f2c854cf5b911f39ee7bd12efb89ee98b49b Mon Sep 17 00:00:00 2001 From: Ratikant Singh Date: Tue, 8 Nov 2022 15:32:47 +0530 Subject: [PATCH 36/55] MAGE-478 --- Helper/ConfigHelper.php | 11 ++++++++++- Helper/Entity/SuggestionHelper.php | 20 ++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Helper/ConfigHelper.php b/Helper/ConfigHelper.php index 0817ff877..0e72b9c3d 100755 --- a/Helper/ConfigHelper.php +++ b/Helper/ConfigHelper.php @@ -108,6 +108,7 @@ class ConfigHelper 'algoliasearch_extra_settings/extra_settings/additional_sections_extra_settings'; public const DEFAULT_MAX_RECORD_SIZE = 10000; + public const MAGENTO_DEFAULT_CACHE_TIME = 'system/full_page_cache/ttl'; protected const IS_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_ENABLED = 'algoliasearch_recommend/recommend/frequently_bought_together/is_frequently_bought_together_enabled'; protected const IS_RECOMMEND_RELATED_PRODUCTS_ENABLED = 'algoliasearch_recommend/recommend/related_product/is_related_products_enabled'; @@ -127,6 +128,7 @@ class ConfigHelper protected const IS_ADDTOCART_ENABLED_IN_RELATED_PRODUCTS= 'algoliasearch_recommend/recommend/related_product/is_addtocart_enabled'; protected const IS_ADDTOCART_ENABLED_IN_TRENDS_ITEM= 'algoliasearch_recommend/recommend/trends_item/is_addtocart_enabled'; + private $configInterface; private $objectManager; private $currency; @@ -530,7 +532,7 @@ public function getNumberOfFrequentlyBoughtTogetherProducts($storeId = null) $storeId ); } - + /** * @param int $storeId * @@ -1331,4 +1333,11 @@ public function getArchiveLogClearLimit($storeId = null) $storeId ); } + + public function getCacheTime($storeId = null) { + return $this->configInterface->getValue(self::MAGENTO_DEFAULT_CACHE_TIME, + ScopeInterface::SCOPE_STORE, + $storeId + ); + } } diff --git a/Helper/Entity/SuggestionHelper.php b/Helper/Entity/SuggestionHelper.php index 581d6510b..7021701bc 100755 --- a/Helper/Entity/SuggestionHelper.php +++ b/Helper/Entity/SuggestionHelper.php @@ -94,9 +94,12 @@ public function getObject(Query $suggestion) return $suggestionObject; } + /** + * @param $storeId + */ public function getPopularQueries($storeId) { - $queries = $this->cache->load($this->popularQueriesCacheId); + $queries = $this->cache->load($this->popularQueriesCacheId .'_'.$storeId); if ($queries !== false) { return $this->serializer->unserialize($queries); } @@ -104,8 +107,8 @@ public function getPopularQueries($storeId) /** @var \Magento\Search\Model\ResourceModel\Query\Collection $collection */ $collection = $this->queryCollectionFactory->create(); $collection->getSelect()->where( - 'num_results >= ' . $this->configHelper->getMinNumberOfResults() . ' - AND popularity >= ' . $this->configHelper->getMinPopularity() . ' + 'num_results >= ' . $this->configHelper->getMinNumberOfResults() . ' + AND popularity >= ' . $this->configHelper->getMinPopularity() . ' AND query_text != "__empty__" AND CHAR_LENGTH(query_text) >= 3' ); @@ -121,7 +124,12 @@ public function getPopularQueries($storeId) $queries = $collection->getColumnValues('query_text'); - $this->cache->save($this->serializer->serialize($queries), $this->popularQueriesCacheId, [], 24*3600); + $this->cache->save( + $this->serializer->serialize($queries), + $this->popularQueriesCacheId .'_'.$storeId, + [], + $this->configHelper->getCacheTime($storeId) + ); return $queries; } @@ -134,8 +142,8 @@ public function getSuggestionCollectionQuery($storeId) ->setStoreId($storeId); $collection->getSelect()->where( - 'num_results >= ' . $this->configHelper->getMinNumberOfResults($storeId) . ' - AND popularity >= ' . $this->configHelper->getMinPopularity($storeId) . ' + 'num_results >= ' . $this->configHelper->getMinNumberOfResults($storeId) . ' + AND popularity >= ' . $this->configHelper->getMinPopularity($storeId) . ' AND query_text != "__empty__"' ); From 670d2bb4ade6cdefc0f86967a914f188aff9d084 Mon Sep 17 00:00:00 2001 From: Ratikant Singh Date: Tue, 8 Nov 2022 15:34:03 +0530 Subject: [PATCH 37/55] MAGE-478 --- Helper/ConfigHelper.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Helper/ConfigHelper.php b/Helper/ConfigHelper.php index 0e72b9c3d..875181a3b 100755 --- a/Helper/ConfigHelper.php +++ b/Helper/ConfigHelper.php @@ -1334,6 +1334,10 @@ public function getArchiveLogClearLimit($storeId = null) ); } + /** + * @param $storeId + * @return mixed + */ public function getCacheTime($storeId = null) { return $this->configInterface->getValue(self::MAGENTO_DEFAULT_CACHE_TIME, ScopeInterface::SCOPE_STORE, From f78e85bbd15712e9e5d595355eb1c089e53aa32f Mon Sep 17 00:00:00 2001 From: rachel-trott Date: Tue, 8 Nov 2022 14:35:50 -0600 Subject: [PATCH 38/55] Cleanup --- Helper/Entity/SuggestionHelper.php | 43 ++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/Helper/Entity/SuggestionHelper.php b/Helper/Entity/SuggestionHelper.php index 7021701bc..71fb1e5f5 100755 --- a/Helper/Entity/SuggestionHelper.php +++ b/Helper/Entity/SuggestionHelper.php @@ -8,10 +8,14 @@ use Magento\Framework\Event\ManagerInterface; use Magento\Framework\Serialize\SerializerInterface; use Magento\Search\Model\Query; +use Magento\Search\Model\ResourceModel\Query\Collection as QueryCollection; use Magento\Search\Model\ResourceModel\Query\CollectionFactory as QueryCollectionFactory; class SuggestionHelper { + /*** + * @var ManagerInterface + */ private $eventManager; /** @@ -19,13 +23,26 @@ class SuggestionHelper */ private $queryCollectionFactory; + /** + * @var ConfigCache + */ private $cache; + /** + * @var ConfigHelper + */ private $configHelper; + /** + * @var SerializerInterface + */ private $serializer; - private $popularQueriesCacheId = 'algoliasearch_popular_queries_cache_tag'; + /** + * @var string + */ + public const POPULAR_QUERIES_CACHE_TAG = 'algoliasearch_popular_queries_cache_tag'; + /** * SuggestionHelper constructor. @@ -50,11 +67,18 @@ public function __construct( $this->serializer = $serializer; } + /** + * @return string + */ public function getIndexNameSuffix() { return '_suggestions'; } + /** + * @param $storeId + * @return array|mixed|null + */ public function getIndexSettings($storeId) { $indexSettings = [ @@ -74,6 +98,10 @@ public function getIndexSettings($storeId) return $indexSettings; } + /** + * @param Query $suggestion + * @return array|mixed|null + */ public function getObject(Query $suggestion) { $suggestionObject = [ @@ -96,15 +124,16 @@ public function getObject(Query $suggestion) /** * @param $storeId + * @return array|bool|float|int|string|null */ public function getPopularQueries($storeId) { - $queries = $this->cache->load($this->popularQueriesCacheId .'_'.$storeId); + $queries = $this->cache->load(self::POPULAR_QUERIES_CACHE_TAG . '_' . $storeId); if ($queries !== false) { return $this->serializer->unserialize($queries); } - /** @var \Magento\Search\Model\ResourceModel\Query\Collection $collection */ + /** @var QueryCollection $collection */ $collection = $this->queryCollectionFactory->create(); $collection->getSelect()->where( 'num_results >= ' . $this->configHelper->getMinNumberOfResults() . ' @@ -126,7 +155,7 @@ public function getPopularQueries($storeId) $this->cache->save( $this->serializer->serialize($queries), - $this->popularQueriesCacheId .'_'.$storeId, + self::POPULAR_QUERIES_CACHE_TAG . '_' . $storeId, [], $this->configHelper->getCacheTime($storeId) ); @@ -134,9 +163,13 @@ public function getPopularQueries($storeId) return $queries; } + /** + * @param $storeId + * @return QueryCollection + */ public function getSuggestionCollectionQuery($storeId) { - /** @var \Magento\Search\Model\ResourceModel\Query\Collection $collection */ + /** @var QueryCollection $collection */ $collection = $this->queryCollectionFactory->create() ->addStoreFilter($storeId) ->setStoreId($storeId); From 44759c94d04dd46c00deaacf5628212de9bf8110 Mon Sep 17 00:00:00 2001 From: Ratikant Singh Date: Fri, 11 Nov 2022 13:06:12 +0530 Subject: [PATCH 39/55] Duplicate Place Order Conversion for Group Products fix --- .../Insights/CheckoutCartProductAddAfter.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Observer/Insights/CheckoutCartProductAddAfter.php b/Observer/Insights/CheckoutCartProductAddAfter.php index 364244752..de117ce1b 100644 --- a/Observer/Insights/CheckoutCartProductAddAfter.php +++ b/Observer/Insights/CheckoutCartProductAddAfter.php @@ -77,7 +77,18 @@ public function execute(Observer $observer) $conversionAnalyticsMode = $this->configHelper->getConversionAnalyticsMode($storeId); switch ($conversionAnalyticsMode) { case 'place_order': - $quoteItem->setData('algoliasearch_query_param', $queryId); + if ($product->getTypeId() == "grouped") { + $groupProducts = $product->getTypeInstance()->getAssociatedProducts($product); + foreach ($quoteItem->getQuote()->getAllItems() as $item) { + foreach ($groupProducts as $groupProduct) { + if ($groupProduct->getId() == $item->getProductId()) { + $item->setData('algoliasearch_query_param', $queryId); + } + } + } + } else { + $quoteItem->setData('algoliasearch_query_param', $queryId); + } break; case 'add_to_cart': try { @@ -91,8 +102,8 @@ public function execute(Observer $observer) $this->logger->critical($e); } } - } - + } + if ($this->personalizationHelper->isPersoEnabled($storeId) && $this->personalizationHelper->isCartAddTracked($storeId) && (!$this->configHelper->isClickConversionAnalyticsEnabled($storeId) || $this->configHelper->getConversionAnalyticsMode($storeId) != 'add_to_cart')) { try { $userClient->convertedObjectIDs( @@ -105,4 +116,4 @@ public function execute(Observer $observer) } } } -} \ No newline at end of file +} From 299787bd5cda78f53414b855138db1ad81785723 Mon Sep 17 00:00:00 2001 From: Ratikant Singh Date: Mon, 14 Nov 2022 21:32:04 +0530 Subject: [PATCH 40/55] Resolve comment --- Observer/Insights/CheckoutCartProductAddAfter.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Observer/Insights/CheckoutCartProductAddAfter.php b/Observer/Insights/CheckoutCartProductAddAfter.php index de117ce1b..cc8bbda68 100644 --- a/Observer/Insights/CheckoutCartProductAddAfter.php +++ b/Observer/Insights/CheckoutCartProductAddAfter.php @@ -73,6 +73,7 @@ public function execute(Observer $observer) $userClient = $this->insightsHelper->getUserInsightsClient(); $queryId = $this->coreSession->getQueryId(); + /** Adding algolia_query_param to the items to track the conversion when product is added to the cart */ if ($this->configHelper->isClickConversionAnalyticsEnabled($storeId) && $queryId) { $conversionAnalyticsMode = $this->configHelper->getConversionAnalyticsMode($storeId); switch ($conversionAnalyticsMode) { @@ -103,7 +104,7 @@ public function execute(Observer $observer) } } } - + /** Tracking the events for add to cart when personalization is enabled */ if ($this->personalizationHelper->isPersoEnabled($storeId) && $this->personalizationHelper->isCartAddTracked($storeId) && (!$this->configHelper->isClickConversionAnalyticsEnabled($storeId) || $this->configHelper->getConversionAnalyticsMode($storeId) != 'add_to_cart')) { try { $userClient->convertedObjectIDs( From 3ecd4700505afc359a3ec85987931670a3602339 Mon Sep 17 00:00:00 2001 From: rachel-trott Date: Mon, 14 Nov 2022 15:58:48 -0600 Subject: [PATCH 41/55] MAGE-305 Set max record size via config --- Helper/AlgoliaHelper.php | 3 +-- Helper/ConfigHelper.php | 15 ++++++--------- etc/adminhtml/system.xml | 8 ++++++++ etc/config.xml | 5 +++++ 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Helper/AlgoliaHelper.php b/Helper/AlgoliaHelper.php index a34ef8160..9cddded4e 100755 --- a/Helper/AlgoliaHelper.php +++ b/Helper/AlgoliaHelper.php @@ -502,8 +502,7 @@ private function prepareRecords(&$objects, $indexName) private function getMaxRecordSize() { if (!$this->maxRecordSize) { - $this->maxRecordSize = $this->config->getMaxRecordSizeLimit() - ? $this->config->getMaxRecordSizeLimit() : $this->config->getDefaultMaxRecordSize(); + $this->maxRecordSize = $this->config->getMaxRecordSizeLimit(); } return $this->maxRecordSize; diff --git a/Helper/ConfigHelper.php b/Helper/ConfigHelper.php index 0817ff877..be5707ad4 100755 --- a/Helper/ConfigHelper.php +++ b/Helper/ConfigHelper.php @@ -107,8 +107,6 @@ class ConfigHelper public const EXTRA_SETTINGS_ADDITIONAL_SECTIONS = 'algoliasearch_extra_settings/extra_settings/additional_sections_extra_settings'; - public const DEFAULT_MAX_RECORD_SIZE = 10000; - protected const IS_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_ENABLED = 'algoliasearch_recommend/recommend/frequently_bought_together/is_frequently_bought_together_enabled'; protected const IS_RECOMMEND_RELATED_PRODUCTS_ENABLED = 'algoliasearch_recommend/recommend/related_product/is_related_products_enabled'; protected const IS_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_ENABLED_ON_CART_PAGE = 'algoliasearch_recommend/recommend/frequently_bought_together/is_frequently_bought_together_enabled_in_cart_page'; @@ -530,7 +528,7 @@ public function getNumberOfFrequentlyBoughtTogetherProducts($storeId = null) $storeId ); } - + /** * @param int $storeId * @@ -1313,14 +1311,13 @@ private function unserialize($value) return $this->serializer->unserialize($value); } - public function getDefaultMaxRecordSize() - { - return self::DEFAULT_MAX_RECORD_SIZE; - } - public function getMaxRecordSizeLimit($storeId = null) { - return self::getDefaultMaxRecordSize(); + return (int) $this->configInterface->getValue( + self::MAX_RECORD_SIZE_LIMIT, + ScopeInterface::SCOPE_STORE, + $storeId + ); } public function getArchiveLogClearLimit($storeId = null) diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 9c7178841..bef02ee3a 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -1165,6 +1165,14 @@ ]]> + + + + + +
diff --git a/etc/config.xml b/etc/config.xml index 269d72f12..c53f5181e 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -55,5 +55,10 @@ + + + 10000 + + From ef8c5f836d98019bcd0b9d7018954dceaf2f1dad Mon Sep 17 00:00:00 2001 From: rachel-trott Date: Mon, 14 Nov 2022 16:42:24 -0600 Subject: [PATCH 42/55] MAGE-305 confighelper cleanup --- Helper/ConfigHelper.php | 968 ++++++++++++++++++++++++++-------------- 1 file changed, 632 insertions(+), 336 deletions(-) diff --git a/Helper/ConfigHelper.php b/Helper/ConfigHelper.php index be5707ad4..798cb127c 100755 --- a/Helper/ConfigHelper.php +++ b/Helper/ConfigHelper.php @@ -4,6 +4,7 @@ use Algolia\AlgoliaSearch\Helper\Entity\SuggestionHelper; use Magento; +use Magento\Customer\Model\ResourceModel\Group\Collection as GroupCollection; use Magento\Directory\Model\Currency as DirCurrency; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\DataObject; @@ -50,7 +51,6 @@ class ConfigHelper public const INDEX_OUT_OF_STOCK_OPTIONS = 'algoliasearch_products/products/index_out_of_stock_options'; public const CATEGORY_ATTRIBUTES = 'algoliasearch_categories/categories/category_additional_attributes'; - public const INDEX_PRODUCT_COUNT = 'algoliasearch_categories/categories/index_product_count'; public const CATEGORY_CUSTOM_RANKING = 'algoliasearch_categories/categories/custom_ranking_category_attributes'; public const SHOW_CATS_NOT_INCLUDED_IN_NAV = 'algoliasearch_categories/categories/show_cats_not_included_in_navigation'; public const INDEX_EMPTY_CATEGORIES = 'algoliasearch_categories/categories/index_empty_categories'; @@ -122,35 +122,90 @@ class ConfigHelper protected const IS_TREND_ITEMS_ENABLED_IN_PDP = 'algoliasearch_recommend/recommend/trends_item/is_trending_items_enabled_on_pdp'; protected const IS_TREND_ITEMS_ENABLED_IN_SHOPPING_CART = 'algoliasearch_recommend/recommend/trends_item/is_trending_items_enabled_on_cart_page'; protected const IS_ADDTOCART_ENABLED_IN_FREQUENTLY_BOUGHT_TOGETHER = 'algoliasearch_recommend/recommend/frequently_bought_together/is_addtocart_enabled'; - protected const IS_ADDTOCART_ENABLED_IN_RELATED_PRODUCTS= 'algoliasearch_recommend/recommend/related_product/is_addtocart_enabled'; - protected const IS_ADDTOCART_ENABLED_IN_TRENDS_ITEM= 'algoliasearch_recommend/recommend/trends_item/is_addtocart_enabled'; - - private $configInterface; - private $objectManager; - private $currency; - private $storeManager; - private $dirCurrency; - private $directoryList; - private $moduleResource; - private $productMetadata; - private $eventManager; - private $currencyManager; - private $serializer; + protected const IS_ADDTOCART_ENABLED_IN_RELATED_PRODUCTS = 'algoliasearch_recommend/recommend/related_product/is_addtocart_enabled'; + protected const IS_ADDTOCART_ENABLED_IN_TRENDS_ITEM = 'algoliasearch_recommend/recommend/trends_item/is_addtocart_enabled'; + /** + * @var Magento\Framework\App\Config\ScopeConfigInterface + */ + protected $configInterface; + + /** + * @var Currency + */ + protected $currency; + + /** + * @var StoreManagerInterface + */ + protected $storeManager; + + /** + * @var DirCurrency + */ + protected $dirCurrency; + + /** + * @var DirectoryList + */ + protected $directoryList; + + /** + * @var Magento\Framework\Module\ResourceInterface + */ + protected $moduleResource; + + /** + * @var Magento\Framework\App\ProductMetadataInterface + */ + protected $productMetadata; + + /** + * @var Magento\Framework\Event\ManagerInterface + */ + protected $eventManager; + + /** + * @var SerializerInterface + */ + protected $serializer; + + /** + * @var GroupCollection + */ + protected $groupCollection; + + /** + * @var SuggestionHelper + */ + protected $suggestionHelper; + + /** + * @param Magento\Framework\App\Config\ScopeConfigInterface $configInterface + * @param StoreManagerInterface $storeManager + * @param Currency $currency + * @param DirCurrency $dirCurrency + * @param DirectoryList $directoryList + * @param Magento\Framework\Module\ResourceInterface $moduleResource + * @param Magento\Framework\App\ProductMetadataInterface $productMetadata + * @param Magento\Framework\Event\ManagerInterface $eventManager + * @param SerializerInterface $serializer + * @param GroupCollection $groupCollection + * @param SuggestionHelper $suggestionHelper + */ public function __construct( Magento\Framework\App\Config\ScopeConfigInterface $configInterface, - Magento\Framework\ObjectManagerInterface $objectManager, - StoreManagerInterface $storeManager, - Currency $currency, - DirCurrency $dirCurrency, - DirectoryList $directoryList, - Magento\Framework\Module\ResourceInterface $moduleResource, - Magento\Framework\App\ProductMetadataInterface $productMetadata, - Magento\Framework\Event\ManagerInterface $eventManager, - Magento\Directory\Model\Currency $currencyManager, - SerializerInterface $serializer + StoreManagerInterface $storeManager, + Currency $currency, + DirCurrency $dirCurrency, + DirectoryList $directoryList, + Magento\Framework\Module\ResourceInterface $moduleResource, + Magento\Framework\App\ProductMetadataInterface $productMetadata, + Magento\Framework\Event\ManagerInterface $eventManager, + SerializerInterface $serializer, + GroupCollection $groupCollection, + SuggestionHelper $suggestionHelper ) { - $this->objectManager = $objectManager; $this->configInterface = $configInterface; $this->currency = $currency; $this->storeManager = $storeManager; @@ -159,10 +214,15 @@ public function __construct( $this->moduleResource = $moduleResource; $this->productMetadata = $productMetadata; $this->eventManager = $eventManager; - $this->currencyManager = $currencyManager; $this->serializer = $serializer; + $this->groupCollection = $groupCollection; + $this->suggestionHelper = $suggestionHelper; } + /** + * @param $storeId + * @return bool + */ public function indexOutOfStockOptions($storeId = null) { return $this->configInterface->isSetFlag( @@ -172,6 +232,10 @@ public function indexOutOfStockOptions($storeId = null) ); } + /** + * @param $storeId + * @return bool + */ public function showCatsNotIncludedInNavigation($storeId = null) { return $this->configInterface->isSetFlag( @@ -181,36 +245,61 @@ public function showCatsNotIncludedInNavigation($storeId = null) ); } + /** + * @param $storeId + * @return bool + */ public function shouldIndexEmptyCategories($storeId = null) { return $this->configInterface->isSetFlag(self::INDEX_EMPTY_CATEGORIES, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @return string + */ public function getMagentoVersion() { return $this->productMetadata->getVersion(); } + /** + * @return string + */ public function getMagentoEdition() { return $this->productMetadata->getEdition(); } + /** + * @return false|string + */ public function getExtensionVersion() { return $this->moduleResource->getDbVersion('Algolia_AlgoliaSearch'); } + /** + * @param $storeId + * @return bool + */ public function isDefaultSelector($storeId = null) { return '.algolia-search-input' === $this->getAutocompleteSelector($storeId); } + /** + * @param $storeId + * @return mixed + */ public function getAutocompleteSelector($storeId = null) { return $this->configInterface->getValue(self::AUTOCOMPLETE_SELECTOR, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return mixed + */ public function indexProductOnCategoryProductsUpdate($storeId = null) { return $this->configInterface->getValue( @@ -220,67 +309,94 @@ public function indexProductOnCategoryProductsUpdate($storeId = null) ); } + /** + * @param $storeId + * @return int + */ public function getNumberOfQueriesSuggestions($storeId = null) { - return (int) $this->configInterface->getValue( + return (int)$this->configInterface->getValue( self::NB_OF_QUERIES_SUGGESTIONS, ScopeInterface::SCOPE_STORE, $storeId ); } + /** + * @param $storeId + * @return int + */ public function getNumberOfProductsSuggestions($storeId = null) { - return (int) $this->configInterface->getValue( + return (int)$this->configInterface->getValue( self::NB_OF_PRODUCTS_SUGGESTIONS, ScopeInterface::SCOPE_STORE, $storeId ); } + /** + * @param $storeId + * @return int + */ public function getNumberOfCategoriesSuggestions($storeId = null) { - return (int) $this->configInterface->getValue( + return (int)$this->configInterface->getValue( self::NB_OF_CATEGORIES_SUGGESTIONS, ScopeInterface::SCOPE_STORE, $storeId ); } - public function showSuggestionsOnNoResultsPage($storeId = null) - { - return $this->configInterface->isSetFlag( - self::SHOW_SUGGESTIONS_NO_RESULTS, - ScopeInterface::SCOPE_STORE, - $storeId - ); - } - + /** + * @param $storeId + * @return bool + */ public function isEnabledFrontEnd($storeId = null) { return $this->configInterface->isSetFlag(self::ENABLE_FRONTEND, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return bool + */ public function isEnabledBackend($storeId = null) { return $this->configInterface->isSetFlag(self::ENABLE_BACKEND, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return bool + */ public function makeSeoRequest($storeId = null) { return $this->configInterface->isSetFlag(self::MAKE_SEO_REQUEST, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return bool + */ public function isLoggingEnabled($storeId = null) { return $this->configInterface->isSetFlag(self::LOGGING_ENABLED, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return bool + */ public function getShowOutOfStock($storeId = null) { return $this->configInterface->isSetFlag(self::SHOW_OUT_OF_STOCK, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return bool + */ public function useSecureUrlsInFrontend($storeId = null) { return $this->configInterface->isSetFlag( @@ -290,6 +406,10 @@ public function useSecureUrlsInFrontend($storeId = null) ); } + /** + * @param $storeId + * @return int + */ public function getImageWidth($storeId = null) { $imageWidth = $this->configInterface->getValue( @@ -302,9 +422,13 @@ public function getImageWidth($storeId = null) return 265; } - return (int) $imageWidth; + return (int)$imageWidth; } + /** + * @param $storeId + * @return int + */ public function getImageHeight($storeId = null) { $imageHeight = $this->configInterface->getValue( @@ -317,29 +441,40 @@ public function getImageHeight($storeId = null) return 265; } - return (int) $imageHeight; + return (int)$imageHeight; } + /** + * @param $storeId + * @return mixed + */ public function getImageType($storeId = null) { return $this->configInterface->getValue(self::XML_PATH_IMAGE_TYPE, ScopeInterface::SCOPE_STORE, $storeId); } - public function isCustomerGroupsEnabled($storeId = null) - { - return $this->configInterface->isSetFlag(self::CUSTOMER_GROUPS_ENABLE, ScopeInterface::SCOPE_STORE, $storeId); - } - + /** + * @param $storeId + * @return bool + */ public function shouldRemovePubDirectory($storeId = null) { return $this->configInterface->isSetFlag(self::REMOVE_PUB_DIR_IN_URL, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return bool + */ public function isPartialUpdateEnabled($storeId = null) { return $this->configInterface->isSetFlag(self::PARTIAL_UPDATES, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return array + */ public function getAutocompleteSections($storeId = null) { $attrs = $this->unserialize($this->configInterface->getValue( @@ -355,16 +490,44 @@ public function getAutocompleteSections($storeId = null) return []; } + /** + * @param $value + * @return array|bool|float|int|mixed|string|null + */ + protected function unserialize($value) + { + if (false === $value || null === $value || '' === $value) { + return false; + } + $unserialized = json_decode($value, true); + if (json_last_error() === JSON_ERROR_NONE) { + return $unserialized; + } + return $this->serializer->unserialize($value); + } + + /** + * @param $storeId + * @return int + */ public function getMinPopularity($storeId = null) { - return (int) $this->configInterface->getValue(self::MIN_POPULARITY, ScopeInterface::SCOPE_STORE, $storeId); + return (int)$this->configInterface->getValue(self::MIN_POPULARITY, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return int + */ public function getMinNumberOfResults($storeId = null) { - return (int) $this->configInterface->getValue(self::MIN_NUMBER_OF_RESULTS, ScopeInterface::SCOPE_STORE, $storeId); + return (int)$this->configInterface->getValue(self::MIN_NUMBER_OF_RESULTS, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return bool + */ public function isAddToCartEnable($storeId = null) { return $this->configInterface->isSetFlag( @@ -374,77 +537,124 @@ public function isAddToCartEnable($storeId = null) ); } + /** + * @param $storeId + * @return bool + */ public function isInfiniteScrollEnabled($storeId = null) { return $this->isInstantEnabled($storeId) && $this->configInterface->isSetFlag(self::INFINITE_SCROLL_ENABLE, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return bool + */ + public function isInstantEnabled($storeId = null) + { + return $this->configInterface->isSetFlag(self::IS_INSTANT_ENABLED, ScopeInterface::SCOPE_STORE, $storeId); + } + + /** + * @param $storeId + * @return bool + */ public function isRemoveBranding($storeId = null) { return $this->configInterface->isSetFlag(self::REMOVE_BRANDING, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return int + */ public function getMaxValuesPerFacet($storeId = null) { - return (int) $this->configInterface->getValue(self::MAX_VALUES_PER_FACET, ScopeInterface::SCOPE_STORE, $storeId); + return (int)$this->configInterface->getValue(self::MAX_VALUES_PER_FACET, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return int + */ public function getNumberOfElementByPage($storeId = null) { - return (int) $this->configInterface->getValue(self::NUMBER_OF_ELEMENT_BY_PAGE, ScopeInterface::SCOPE_STORE, $storeId); + return (int)$this->configInterface->getValue(self::NUMBER_OF_ELEMENT_BY_PAGE, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return mixed + */ public function getNumberOfJobToRun($storeId = null) { - $nbJobs = (int) $this->configInterface->getValue(self::NUMBER_OF_JOB_TO_RUN, ScopeInterface::SCOPE_STORE, $storeId); + $nbJobs = (int)$this->configInterface->getValue(self::NUMBER_OF_JOB_TO_RUN, ScopeInterface::SCOPE_STORE, $storeId); return max($nbJobs, 1); } + /** + * @param $storeId + * @return int + */ public function getRetryLimit($storeId = null) { - return (int) $this->configInterface->getValue(self::RETRY_LIMIT, ScopeInterface::SCOPE_STORE, $storeId); + return (int)$this->configInterface->getValue(self::RETRY_LIMIT, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return bool + */ public function isQueueActive($storeId = null) { return $this->configInterface->isSetFlag(self::IS_ACTIVE, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return mixed + */ public function getRemoveWordsIfNoResult($storeId = null) { return $this->configInterface->getValue(self::REMOVE_IF_NO_RESULT, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return int + */ public function getNumberOfProductResults($storeId = null) { - return (int) $this->configInterface->getValue( + return (int)$this->configInterface->getValue( self::NUMBER_OF_PRODUCT_RESULTS, ScopeInterface::SCOPE_STORE, $storeId ); } + /** + * @param $storeId + * @return bool + */ public function replaceCategories($storeId = null) { return $this->configInterface->isSetFlag(self::REPLACE_CATEGORIES, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return bool + */ public function isAutoCompleteEnabled($storeId = null) { return $this->configInterface->isSetFlag(self::IS_POPUP_ENABLED, ScopeInterface::SCOPE_STORE, $storeId); } - public function isInstantEnabled($storeId = null) - { - return $this->configInterface->isSetFlag(self::IS_INSTANT_ENABLED, ScopeInterface::SCOPE_STORE, $storeId); - } - /** - * @param int $storeId - * - * @return int + * @param $storeId + * @return bool */ public function isRecommendFrequentlyBroughtTogetherEnabled($storeId = null) { @@ -452,9 +662,8 @@ public function isRecommendFrequentlyBroughtTogetherEnabled($storeId = null) } /** - * @param int $storeId - * - * @return int + * @param $storeId + * @return bool */ public function isRecommendRelatedProductsEnabled($storeId = null) { @@ -462,9 +671,8 @@ public function isRecommendRelatedProductsEnabled($storeId = null) } /** - * @param int $storeId - * - * @return int + * @param $storeId + * @return bool */ public function isRecommendFrequentlyBroughtTogetherEnabledOnCartPage($storeId = null) { @@ -472,9 +680,8 @@ public function isRecommendFrequentlyBroughtTogetherEnabledOnCartPage($storeId = } /** - * @param int $storeId - * - * @return int + * @param $storeId + * @return bool */ public function isRecommendRelatedProductsEnabledOnCartPage($storeId = null) { @@ -482,9 +689,8 @@ public function isRecommendRelatedProductsEnabledOnCartPage($storeId = null) } /** - * @param int $storeId - * - * @return int + * @param $storeId + * @return bool */ public function isRemoveCoreRelatedProductsBlock($storeId = null) { @@ -492,9 +698,8 @@ public function isRemoveCoreRelatedProductsBlock($storeId = null) } /** - * @param int $storeId - * - * @return int + * @param $storeId + * @return bool */ public function isRemoveUpsellProductsBlock($storeId = null) { @@ -502,13 +707,12 @@ public function isRemoveUpsellProductsBlock($storeId = null) } /** - * @param int $storeId - * + * @param $storeId * @return int */ public function getNumberOfRelatedProducts($storeId = null) { - return (int) $this->configInterface->getValue( + return (int)$this->configInterface->getValue( self::NUM_OF_RECOMMEND_RELATED_PRODUCTS, ScopeInterface::SCOPE_STORE, $storeId @@ -516,27 +720,25 @@ public function getNumberOfRelatedProducts($storeId = null) } /** - * @param int $storeId - * + * @param $storeId * @return int */ public function getNumberOfFrequentlyBoughtTogetherProducts($storeId = null) { - return (int) $this->configInterface->getValue( + return (int)$this->configInterface->getValue( self::NUM_OF_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_PRODUCTS, ScopeInterface::SCOPE_STORE, $storeId ); } - /** - * @param int $storeId - * + /** + * @param $storeId * @return int */ public function isRecommendTrendingItemsEnabled($storeId = null) { - return (int) $this->configInterface->getValue( + return (int)$this->configInterface->getValue( self::IS_RECOMMEND_TRENDING_ITEMS_ENABLED, ScopeInterface::SCOPE_STORE, $storeId @@ -544,24 +746,21 @@ public function isRecommendTrendingItemsEnabled($storeId = null) } /** - * @param int $storeId - * + * @param $storeId * @return int */ public function getNumberOfTrendingItems($storeId = null) { - return (int) $this->configInterface->getValue( + return (int)$this->configInterface->getValue( self::NUM_OF_TRENDING_ITEMS, ScopeInterface::SCOPE_STORE, $storeId ); } - /** - * @param int $storeId - * - * @return string + * @param $storeId + * @return mixed */ public function getTrendingItemsFacetName($storeId = null) { @@ -573,9 +772,8 @@ public function getTrendingItemsFacetName($storeId = null) } /** - * @param int $storeId - * - * @return string + * @param $storeId + * @return mixed */ public function getTrendingItemsFacetValue($storeId = null) { @@ -587,13 +785,12 @@ public function getTrendingItemsFacetValue($storeId = null) } /** - * @param int $storeId - * + * @param $storeId * @return int */ public function isTrendItemsEnabledInPDP($storeId = null) { - return (int) $this->configInterface->getValue( + return (int)$this->configInterface->getValue( self::IS_TREND_ITEMS_ENABLED_IN_PDP, ScopeInterface::SCOPE_STORE, $storeId @@ -601,13 +798,12 @@ public function isTrendItemsEnabledInPDP($storeId = null) } /** - * @param int $storeId - * + * @param $storeId * @return int */ public function isTrendItemsEnabledInShoppingCart($storeId = null) { - return (int) $this->configInterface->getValue( + return (int)$this->configInterface->getValue( self::IS_TREND_ITEMS_ENABLED_IN_SHOPPING_CART, ScopeInterface::SCOPE_STORE, $storeId @@ -615,9 +811,8 @@ public function isTrendItemsEnabledInShoppingCart($storeId = null) } /** - * @param int $storeId - * - * @return int + * @param $storeId + * @return bool */ public function isAddToCartEnabledInFrequentlyBoughtTogether($storeId = null) { @@ -625,9 +820,8 @@ public function isAddToCartEnabledInFrequentlyBoughtTogether($storeId = null) } /** - * @param int $storeId - * - * @return int + * @param $storeId + * @return bool */ public function isAddToCartEnabledInRelatedProducts($storeId = null) { @@ -635,25 +829,36 @@ public function isAddToCartEnabledInRelatedProducts($storeId = null) } /** - * @param int $storeId - * - * @return int + * @param $storeId + * @return bool */ public function isAddToCartEnabledInTrendsItem($storeId = null) { return $this->configInterface->isSetFlag(self::IS_ADDTOCART_ENABLED_IN_TRENDS_ITEM, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return bool + */ public function useAdaptiveImage($storeId = null) { return $this->configInterface->isSetFlag(self::USE_ADAPTIVE_IMAGE, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return mixed + */ public function getInstantSelector($storeId = null) { return $this->configInterface->getValue(self::INSTANT_SELECTOR, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return array + */ public function getExcludedPages($storeId = null) { $attrs = $this->unserialize($this->configInterface->getValue( @@ -661,14 +866,16 @@ public function getExcludedPages($storeId = null) ScopeInterface::SCOPE_STORE, $storeId )); - if (is_array($attrs)) { return $attrs; } - return []; } + /** + * @param $storeId + * @return mixed + */ public function getRenderTemplateDirectives($storeId = null) { return $this->configInterface->getValue( @@ -678,62 +885,49 @@ public function getRenderTemplateDirectives($storeId = null) ); } + /** + * @param $storeId + * @return bool + */ public function isAutocompleteDebugEnabled($storeId = null) { return $this->configInterface->isSetFlag(self::AUTOCOMPLETE_MENU_DEBUG, ScopeInterface::SCOPE_STORE, $storeId); } - public function getRawSortingValue($storeId = null) - { - return $this->configInterface->getValue( - self::SORTING_INDICES, - ScopeInterface::SCOPE_STORE, - $storeId - ); - } - - public function getSorting($storeId = null) - { - return $this->unserialize($this->getRawSortingValue($storeId)); - } - + /** + * @param $originalIndexName + * @param $storeId + * @param $currentCustomerGroupId + * @return array + * @throws Magento\Framework\Exception\NoSuchEntityException + */ public function getSortingIndices($originalIndexName, $storeId = null, $currentCustomerGroupId = null) { $attrs = $this->getSorting($storeId); - $currency = $this->getCurrencyCode($storeId); $attributesToAdd = []; - foreach ($attrs as $key => $attr) { $indexName = false; $sortAttribute = false; - if ($this->isCustomerGroupsEnabled($storeId) && $attr['attribute'] === 'price') { - /** @var Magento\Customer\Model\ResourceModel\Group\Collection $groupCollection */ - $groupCollection = $this->objectManager->get('Magento\Customer\Model\ResourceModel\Group\Collection'); - + $groupCollection = $this->groupCollection; if (!is_null($currentCustomerGroupId)) { $groupCollection->addFilter('customer_group_id', $currentCustomerGroupId); } - foreach ($groupCollection as $group) { - $customerGroupId = (int) $group->getData('customer_group_id'); + $customerGroupId = (int)$group->getData('customer_group_id'); $groupIndexNameSuffix = 'group_' . $customerGroupId; - $groupIndexName = $originalIndexName . '_' . $attr['attribute'] . '_' . $groupIndexNameSuffix . '_' . $attr['sort']; $groupSortAttribute = $attr['attribute'] . '.' . $currency . '.' . $groupIndexNameSuffix; - $newAttr = []; $newAttr['name'] = $groupIndexName; $newAttr['attribute'] = $attr['attribute']; $newAttr['sort'] = $attr['sort']; $newAttr['sortLabel'] = $attr['sortLabel']; - if (!array_key_exists('label', $newAttr) && array_key_exists('sortLabel', $newAttr)) { $newAttr['label'] = $newAttr['sortLabel']; } - $newAttr['ranking'] = [ $newAttr['sort'] . '(' . $groupSortAttribute . ')', 'typo', @@ -745,7 +939,6 @@ public function getSortingIndices($originalIndexName, $storeId = null, $currentC 'exact', 'custom', ]; - $attributesToAdd[$newAttr['sort']][] = $newAttr; } } elseif ($attr['attribute'] === 'price') { @@ -755,14 +948,11 @@ public function getSortingIndices($originalIndexName, $storeId = null, $currentC $indexName = $originalIndexName . '_' . $attr['attribute'] . '_' . $attr['sort']; $sortAttribute = $attr['attribute']; } - if ($indexName && $sortAttribute) { $attrs[$key]['name'] = $indexName; - if (!array_key_exists('label', $attrs[$key]) && array_key_exists('sortLabel', $attrs[$key])) { $attrs[$key]['label'] = $attrs[$key]['sortLabel']; } - $attrs[$key]['ranking'] = [ $attr['sort'] . '(' . $sortAttribute . ')', 'typo', @@ -776,9 +966,7 @@ public function getSortingIndices($originalIndexName, $storeId = null, $currentC ]; } } - $attrsToReturn = []; - if (count($attributesToAdd) > 0) { foreach ($attrs as $key => $attr) { if ($attr['attribute'] == 'price' && isset($attributesToAdd[$attr['sort']])) { @@ -788,113 +976,109 @@ public function getSortingIndices($originalIndexName, $storeId = null, $currentC } } } - if (count($attrsToReturn) > 0) { return $attrsToReturn; } - if (is_array($attrs)) { return $attrs; } - return []; } - public function getApplicationID($storeId = null) + /*** + * @param $storeId + * @return array|bool|float|int|mixed|string|null + */ + public function getSorting($storeId = null) { - return $this->configInterface->getValue(self::APPLICATION_ID, ScopeInterface::SCOPE_STORE, $storeId); + return $this->unserialize($this->getRawSortingValue($storeId)); } - public function getAPIKey($storeId = null) + /** + * @param $storeId + * @return mixed + */ + public function getRawSortingValue($storeId = null) { - return $this->configInterface->getValue(self::API_KEY, ScopeInterface::SCOPE_STORE, $storeId); + return $this->configInterface->getValue( + self::SORTING_INDICES, + ScopeInterface::SCOPE_STORE, + $storeId + ); } - public function getSearchOnlyAPIKey($storeId = null) + /** + * @param $storeId + * @return string + * @throws Magento\Framework\Exception\NoSuchEntityException + */ + public function getCurrencyCode($storeId = null) { - return $this->configInterface->getValue(self::SEARCH_ONLY_API_KEY, ScopeInterface::SCOPE_STORE, $storeId); + /** @var Magento\Store\Model\Store $store */ + $store = $this->storeManager->getStore($storeId); + return $store->getCurrentCurrencyCode(); } - public function credentialsAreConfigured($storeId = null) + /** + * @param $storeId + * @return bool + */ + public function isCustomerGroupsEnabled($storeId = null) + { + return $this->configInterface->isSetFlag(self::CUSTOMER_GROUPS_ENABLE, ScopeInterface::SCOPE_STORE, $storeId); + } + + /** + * @param $storeId + * @return bool + */ + public function credentialsAreConfigured($storeId = null) { return $this->getApplicationID($storeId) && $this->getAPIKey($storeId) && $this->getSearchOnlyAPIKey($storeId); } - public function getIndexPrefix($storeId = null) + /** + * @param $storeId + * @return mixed' + */ + public function getApplicationID($storeId = null) { - return $this->configInterface->getValue(self::INDEX_PREFIX, ScopeInterface::SCOPE_STORE, $storeId); + return $this->configInterface->getValue(self::APPLICATION_ID, ScopeInterface::SCOPE_STORE, $storeId); } - public function getCategoryAdditionalAttributes($storeId = null) + /** + * @param $storeId + * @return mixed + */ + public function getAPIKey($storeId = null) { - $attributes = $this->unserialize($this->configInterface->getValue( - self::CATEGORY_ATTRIBUTES, - ScopeInterface::SCOPE_STORE, - $storeId - )); - - $customRankings = $this->unserialize($this->configInterface->getValue( - self::CATEGORY_CUSTOM_RANKING, - ScopeInterface::SCOPE_STORE, - $storeId - )); - - $customRankings = $customRankings ?: []; - $customRankings = array_filter($customRankings, function ($customRanking) { - return $customRanking['attribute'] !== 'custom_attribute'; - }); - $attributes = $this->addIndexableAttributes($attributes, $customRankings, '0', '0'); - - if (is_array($attributes)) { - return $attributes; - } - - return []; + return $this->configInterface->getValue(self::API_KEY, ScopeInterface::SCOPE_STORE, $storeId); } - public function getProductAdditionalAttributes($storeId = null) + /** + * @param $storeId + * @return mixed + */ + public function getSearchOnlyAPIKey($storeId = null) { - $attributes = $this->unserialize($this->configInterface->getValue( - self::PRODUCT_ATTRIBUTES, - ScopeInterface::SCOPE_STORE, - $storeId - )); - - $facets = $this->unserialize($this->configInterface->getValue( - self::FACETS, - ScopeInterface::SCOPE_STORE, - $storeId - )); - $attributes = $this->addIndexableAttributes($attributes, $facets, '0'); - - $sorts = $this->unserialize($this->configInterface->getValue( - self::SORTING_INDICES, - ScopeInterface::SCOPE_STORE, - $storeId - )); - $attributes = $this->addIndexableAttributes($attributes, $sorts, '0'); - - $customRankings = $this->unserialize($this->configInterface->getValue( - self::PRODUCT_CUSTOM_RANKING, - ScopeInterface::SCOPE_STORE, - $storeId - )); - - $customRankings = $customRankings ?: []; - $customRankings = array_filter($customRankings, function ($customRanking) { - return $customRanking['attribute'] !== 'custom_attribute'; - }); - $attributes = $this->addIndexableAttributes($attributes, $customRankings, '0', '0'); - - if (is_array($attributes)) { - return $attributes; - } + return $this->configInterface->getValue(self::SEARCH_ONLY_API_KEY, ScopeInterface::SCOPE_STORE, $storeId); + } - return []; + /** + * @param $storeId + * @return mixed + */ + public function getIndexPrefix($storeId = null) + { + return $this->configInterface->getValue(self::INDEX_PREFIX, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return array|bool|float|int|mixed|string + */ public function getFacets($storeId = null) { $attrs = $this->unserialize($this->configInterface->getValue( @@ -902,22 +1086,23 @@ public function getFacets($storeId = null) ScopeInterface::SCOPE_STORE, $storeId )); - if ($attrs) { foreach ($attrs as &$attr) { if ($attr['type'] === 'other') { $attr['type'] = $attr['other_type']; } } - if (is_array($attrs)) { return array_values($attrs); } } - return []; } + /** + * @param $storeId + * @return array + */ public function getCategoryCustomRanking($storeId = null) { $attrs = $this->unserialize($this->configInterface->getValue( @@ -925,17 +1110,27 @@ public function getCategoryCustomRanking($storeId = null) ScopeInterface::SCOPE_STORE, $storeId )); - if (is_array($attrs)) { return $attrs; } + return []; + } + /** + * @param $storeId + * @return array + */ + public function getProductCustomRanking($storeId = null) + { + $attrs = $this->unserialize($this->getRawProductCustomRanking($storeId)); + if (is_array($attrs)) { + return $attrs; + } return []; } /** - * @param int|null $storeId - * + * @param $storeId * @return mixed */ public function getRawProductCustomRanking($storeId = null) @@ -948,30 +1143,21 @@ public function getRawProductCustomRanking($storeId = null) } /** - * @param int|null $storeId - * - * @return array|mixed + * @param $section + * @param $storeId + * @return string */ - public function getProductCustomRanking($storeId = null) - { - $attrs = $this->unserialize($this->getRawProductCustomRanking($storeId)); - - if (is_array($attrs)) { - return $attrs; - } - - return []; - } - public function getExtraSettings($section, $storeId = null) { $constant = 'EXTRA_SETTINGS_' . mb_strtoupper($section); - $value = $this->configInterface->getValue(constant('self::' . $constant), ScopeInterface::SCOPE_STORE, $storeId); - - return trim((string) $value); + return trim((string)$value); } + /** + * @param $storeId + * @return bool + */ public function preventBackendRendering($storeId = null) { $preventBackendRendering = $this->configInterface->isSetFlag( @@ -979,42 +1165,37 @@ public function preventBackendRendering($storeId = null) ScopeInterface::SCOPE_STORE, $storeId ); - if ($preventBackendRendering === false) { return false; } - if (!isset($_SERVER['HTTP_USER_AGENT'])) { return false; } - $userAgent = mb_strtolower($_SERVER['HTTP_USER_AGENT'], 'utf-8'); - $allowedUserAgents = $this->configInterface->getValue( self::BACKEND_RENDERING_ALLOWED_USER_AGENTS, ScopeInterface::SCOPE_STORE, $storeId ); - $allowedUserAgents = trim($allowedUserAgents); - if ($allowedUserAgents === '') { return true; } - $allowedUserAgents = preg_split('/\n|\r\n?/', $allowedUserAgents); $allowedUserAgents = array_filter($allowedUserAgents); - foreach ($allowedUserAgents as $allowedUserAgent) { $allowedUserAgent = mb_strtolower($allowedUserAgent, 'utf-8'); if (mb_strpos($userAgent, $allowedUserAgent) !== false) { return false; } } - return true; } + /** + * @param $storeId + * @return mixed + */ public function getBackendRenderingDisplayMode($storeId = null) { return $this->configInterface->getValue( @@ -1024,11 +1205,19 @@ public function getBackendRenderingDisplayMode($storeId = null) ); } + /** + * @return int + * @throws Magento\Framework\Exception\NoSuchEntityException + */ public function getStoreId() { return $this->storeManager->getStore()->getId(); } + /** + * @param $storeId + * @return mixed + */ public function getStoreLocale($storeId) { return $this->configInterface->getValue( @@ -1038,61 +1227,68 @@ public function getStoreLocale($storeId) ); } + /** + * @param $storeId + * @return string|null + * @throws Magento\Framework\Exception\NoSuchEntityException + */ public function getCurrency($storeId = null) { /** @var Magento\Store\Model\Store $store */ $store = $this->storeManager->getStore($storeId); - $currencySymbol = $this->currency->getCurrency($store->getCurrentCurrencyCode())->getSymbol(); - - return $currencySymbol; - } - - public function getCurrencyCode($storeId = null) - { - /** @var Magento\Store\Model\Store $store */ - $store = $this->storeManager->getStore($storeId); - $code = $store->getCurrentCurrencyCode(); - - return $code; + return $this->currency->getCurrency($store->getCurrentCurrencyCode())->getSymbol(); } + /** + * @param $storeId + * @return array|bool|float|int|string|null + * @throws Magento\Framework\Exception\NoSuchEntityException + */ public function getPopularQueries($storeId = null) { if (!$this->isInstantEnabled($storeId) || !$this->showSuggestionsOnNoResultsPage($storeId)) { return []; } - if ($storeId === null) { $storeId = $this->storeManager->getStore()->getId(); } + $suggestionHelper = $this->suggestionHelper; + return $suggestionHelper->getPopularQueries($storeId); + } - /** @var SuggestionHelper $suggestionHelper */ - $suggestionHelper = $this->objectManager->create('Algolia\AlgoliaSearch\Helper\Entity\SuggestionHelper'); - $popularQueries = $suggestionHelper->getPopularQueries($storeId); - - return $popularQueries; + /** + * @param $storeId + * @return bool + */ + public function showSuggestionsOnNoResultsPage($storeId = null) + { + return $this->configInterface->isSetFlag( + self::SHOW_SUGGESTIONS_NO_RESULTS, + ScopeInterface::SCOPE_STORE, + $storeId + ); } + /** + * @param $groupId + * @return array + */ public function getAttributesToRetrieve($groupId) { if (false === $this->isCustomerGroupsEnabled()) { return []; } - $attributes = []; - foreach ($this->getProductAdditionalAttributes() as $attribute) { if ($attribute['attribute'] !== 'price' && $attribute['retrievable'] === '1') { $attributes[] = $attribute['attribute']; } } - foreach ($this->getCategoryAdditionalAttributes() as $attribute) { if ($attribute['retrievable'] === '1') { $attributes[] = $attribute['attribute']; } } - $attributes = array_merge($attributes, [ 'objectID', 'name', @@ -1110,9 +1306,7 @@ public function getAttributesToRetrieve($groupId) 'query', # suggestions 'path', # categories ]); - $currencies = $this->dirCurrency->getConfigAllowCurrencies(); - foreach ($currencies as $currency) { $attributes[] = 'price.' . $currency . '.default'; $attributes[] = 'price.' . $currency . '.default_tier'; @@ -1129,17 +1323,118 @@ public function getAttributesToRetrieve($groupId) $attributes[] = 'price.' . $currency . '.special_from_date'; $attributes[] = 'price.' . $currency . '.special_to_date'; } - $transport = new DataObject($attributes); $this->eventManager->dispatch('algolia_get_retrievable_attributes', ['attributes' => $transport]); $attributes = $transport->getData(); - $attributes = array_unique($attributes); $attributes = array_values($attributes); - return ['attributesToRetrieve' => $attributes]; } + /** + * @param $storeId + * @return array + */ + public function getProductAdditionalAttributes($storeId = null) + { + $attributes = $this->unserialize($this->configInterface->getValue( + self::PRODUCT_ATTRIBUTES, + ScopeInterface::SCOPE_STORE, + $storeId + )); + + $facets = $this->unserialize($this->configInterface->getValue( + self::FACETS, + ScopeInterface::SCOPE_STORE, + $storeId + )); + $attributes = $this->addIndexableAttributes($attributes, $facets, '0'); + + $sorts = $this->unserialize($this->configInterface->getValue( + self::SORTING_INDICES, + ScopeInterface::SCOPE_STORE, + $storeId + )); + $attributes = $this->addIndexableAttributes($attributes, $sorts, '0'); + + $customRankings = $this->unserialize($this->configInterface->getValue( + self::PRODUCT_CUSTOM_RANKING, + ScopeInterface::SCOPE_STORE, + $storeId + )); + $customRankings = $customRankings ?: []; + $customRankings = array_filter($customRankings, function ($customRanking) { + return $customRanking['attribute'] !== 'custom_attribute'; + }); + $attributes = $this->addIndexableAttributes($attributes, $customRankings, '0', '0'); + if (is_array($attributes)) { + return $attributes; + } + return []; + } + + /** + * @param $attributes + * @param $addedAttributes + * @param $searchable + * @param $retrievable + * @param $indexNoValue + * @return mixed + */ + protected function addIndexableAttributes( + $attributes, + $addedAttributes, + $searchable = '1', + $retrievable = '1', + $indexNoValue = '1' + ) { + foreach ((array)$addedAttributes as $addedAttribute) { + foreach ((array)$attributes as $attribute) { + if ($addedAttribute['attribute'] === $attribute['attribute']) { + continue 2; + } + } + $attributes[] = [ + 'attribute' => $addedAttribute['attribute'], + 'searchable' => $searchable, + 'retrievable' => $retrievable, + 'index_no_value' => $indexNoValue, + ]; + } + return $attributes; + } + + /** + * @param $storeId + * @return array + */ + public function getCategoryAdditionalAttributes($storeId = null) + { + $attributes = $this->unserialize($this->configInterface->getValue( + self::CATEGORY_ATTRIBUTES, + ScopeInterface::SCOPE_STORE, + $storeId + )); + $customRankings = $this->unserialize($this->configInterface->getValue( + self::CATEGORY_CUSTOM_RANKING, + ScopeInterface::SCOPE_STORE, + $storeId + )); + $customRankings = $customRankings ?: []; + $customRankings = array_filter($customRankings, function ($customRanking) { + return $customRanking['attribute'] !== 'custom_attribute'; + }); + $attributes = $this->addIndexableAttributes($attributes, $customRankings, '0', '0'); + if (is_array($attributes)) { + return $attributes; + } + return []; + } + + /** + * @param $groupId + * @return array + */ public function getAttributesToFilter($groupId) { $transport = new DataObject(); @@ -1148,18 +1443,24 @@ public function getAttributesToFilter($groupId) ['filter_object' => $transport, 'customer_group_id' => $groupId] ); $attributes = $transport->getData(); - $attributes = array_unique($attributes); $attributes = array_values($attributes); - return count($attributes) ? ['filters' => implode(' AND ', $attributes)] : []; } + /** + * @param $storeId + * @return bool + */ public function isEnabledSynonyms($storeId = null) { return $this->configInterface->isSetFlag(self::ENABLE_SYNONYMS, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return array + */ public function getSynonyms($storeId = null) { $synonyms = $this->unserialize($this->configInterface->getValue( @@ -1167,14 +1468,16 @@ public function getSynonyms($storeId = null) ScopeInterface::SCOPE_STORE, $storeId )); - if (is_array($synonyms)) { return $synonyms; } - return []; } + /** + * @param $storeId + * @return array + */ public function getOnewaySynonyms($storeId = null) { $onewaySynonyms = $this->unserialize($this->configInterface->getValue( @@ -1182,37 +1485,49 @@ public function getOnewaySynonyms($storeId = null) ScopeInterface::SCOPE_STORE, $storeId )); - if (is_array($onewaySynonyms)) { return $onewaySynonyms; } - return []; } + /** + * @param $storeId + * @return string|null + * @throws Magento\Framework\Exception\FileSystemException + */ public function getSynonymsFile($storeId = null) { $filename = $this->configInterface->getValue(self::SYNONYMS_FILE, ScopeInterface::SCOPE_STORE, $storeId); - if (!$filename) { return null; } - $baseDirectory = $this->directoryList->getPath(DirectoryList::MEDIA); - return $baseDirectory . '/algoliasearch_admin_config_uploads/' . $filename; } + /** + * @param $storeId + * @return bool + */ public function isClickConversionAnalyticsEnabled($storeId = null) { return $this->configInterface->isSetFlag(self::CC_ANALYTICS_ENABLE, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return mixed + */ public function getClickConversionAnalyticsISSelector($storeId = null) { return $this->configInterface->getValue(self::CC_ANALYTICS_IS_SELECTOR, ScopeInterface::SCOPE_STORE, $storeId); } + /** + * @param $storeId + * @return mixed + */ public function getConversionAnalyticsMode($storeId = null) { return $this->configInterface->getValue( @@ -1222,16 +1537,19 @@ public function getConversionAnalyticsMode($storeId = null) ); } + /** + * @param $storeId + * @return mixed + */ public function getConversionAnalyticsAddToCartSelector($storeId = null) { return $this->configInterface->getValue(self::CC_ADD_TO_CART_SELECTOR, ScopeInterface::SCOPE_STORE, $storeId); } - public function isAnalyticsEnabled($storeId = null) - { - return $this->configInterface->isSetFlag(self::GA_ENABLE, ScopeInterface::SCOPE_STORE, $storeId); - } - + /** + * @param $storeId + * @return array + */ public function getAnalyticsConfig($storeId = null) { return [ @@ -1250,16 +1568,27 @@ public function getAnalyticsConfig($storeId = null) ]; } + /** + * @param $storeId + * @return bool + */ + public function isAnalyticsEnabled($storeId = null) + { + return $this->configInterface->isSetFlag(self::GA_ENABLE, ScopeInterface::SCOPE_STORE, $storeId); + } + + /** + * @param $storeId + * @return array + */ public function getNonCastableAttributes($storeId = null) { $nonCastableAttributes = []; - $config = $this->unserialize($this->configInterface->getValue( self::NON_CASTABLE_ATTRIBUTES, ScopeInterface::SCOPE_STORE, $storeId )); - if (is_array($config)) { foreach ($config as $attributeData) { if (isset($attributeData['attribute'])) { @@ -1267,62 +1596,29 @@ public function getNonCastableAttributes($storeId = null) } } } - return $nonCastableAttributes; } - private function addIndexableAttributes( - $attributes, - $addedAttributes, - $searchable = '1', - $retrievable = '1', - $indexNoValue = '1' - ) { - foreach ((array) $addedAttributes as $addedAttribute) { - foreach ((array) $attributes as $attribute) { - if ($addedAttribute['attribute'] === $attribute['attribute']) { - continue 2; - } - } - - $attributes[] = [ - 'attribute' => $addedAttribute['attribute'], - 'searchable' => $searchable, - 'retrievable' => $retrievable, - 'index_no_value' => $indexNoValue, - ]; - } - - return $attributes; - } - - private function unserialize($value) - { - if (false === $value || null === $value || '' === $value) { - return false; - } - - $unserialized = json_decode($value, true); - - if (json_last_error() === JSON_ERROR_NONE) { - return $unserialized; - } - - return $this->serializer->unserialize($value); - } - + /** + * @param $storeId + * @return int + */ public function getMaxRecordSizeLimit($storeId = null) { - return (int) $this->configInterface->getValue( + return (int)$this->configInterface->getValue( self::MAX_RECORD_SIZE_LIMIT, ScopeInterface::SCOPE_STORE, $storeId ); } + /** + * @param $storeId + * @return int + */ public function getArchiveLogClearLimit($storeId = null) { - return (int) $this->configInterface->getValue( + return (int)$this->configInterface->getValue( self::ARCHIVE_LOG_CLEAR_LIMIT, ScopeInterface::SCOPE_STORE, $storeId From 1ea25556440ed85ace39419cfb32963c4a06ff6e Mon Sep 17 00:00:00 2001 From: Mohit Choudhary Date: Tue, 15 Nov 2022 15:19:16 +0530 Subject: [PATCH 43/55] Updated the synonym area text to point customers to use algolia dashboard --- view/adminhtml/web/js/config.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/view/adminhtml/web/js/config.js b/view/adminhtml/web/js/config.js index 2ef66b1b5..5010aca05 100644 --- a/view/adminhtml/web/js/config.js +++ b/view/adminhtml/web/js/config.js @@ -37,11 +37,17 @@ require( pageWarning += '

These settings are also available in the Algolia Dashboard. We advise you to manage it from this page, because saving Magento settings will override the Algolia settings.

'; pageWarning += '
'; + var pageWarningSynonyms = '
'; + pageWarningSynonyms += '

These settings are also available in the Algolia Dashboard. We advise you to configure synonyms configuration from the Algolia dashboard as this is going to be be deprecated in release 3.9.2.

'; + pageWarningSynonyms += '
'; + for (var i=0; i < pageIds.length; i++) { var element = $(pageIds[i]); - if (element.length > 0) { + if (element.length > 0 && pageIds[i] != "#algoliasearch_synonyms_synonyms_group") { element.find('.comment').append(pageWarning); - } + } else if (element.length > 0 && pageIds[i] == "#algoliasearch_synonyms_synonyms_group"){ + element.find('.comment').append(pageWarningSynonyms); + } } } From 80889de393509d48c373555c7f9bb04c0e910727 Mon Sep 17 00:00:00 2001 From: Mohit Choudhary Date: Tue, 15 Nov 2022 15:21:35 +0530 Subject: [PATCH 44/55] Updated the synonym area text to point customers to use algolia dashboard --- view/adminhtml/web/js/config.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/view/adminhtml/web/js/config.js b/view/adminhtml/web/js/config.js index 5010aca05..ee44d7b25 100644 --- a/view/adminhtml/web/js/config.js +++ b/view/adminhtml/web/js/config.js @@ -37,17 +37,17 @@ require( pageWarning += '

These settings are also available in the Algolia Dashboard. We advise you to manage it from this page, because saving Magento settings will override the Algolia settings.

'; pageWarning += '
'; - var pageWarningSynonyms = '
'; - pageWarningSynonyms += '

These settings are also available in the Algolia Dashboard. We advise you to configure synonyms configuration from the Algolia dashboard as this is going to be be deprecated in release 3.9.2.

'; - pageWarningSynonyms += '
'; + var pageWarningSynonyms = '
'; + pageWarningSynonyms += '

These settings are also available in the Algolia Dashboard. We advise you to configure synonyms configuration from the Algolia dashboard as this is going to be be deprecated in release 3.9.2.

'; + pageWarningSynonyms += '
'; for (var i=0; i < pageIds.length; i++) { var element = $(pageIds[i]); if (element.length > 0 && pageIds[i] != "#algoliasearch_synonyms_synonyms_group") { element.find('.comment').append(pageWarning); } else if (element.length > 0 && pageIds[i] == "#algoliasearch_synonyms_synonyms_group"){ - element.find('.comment').append(pageWarningSynonyms); - } + element.find('.comment').append(pageWarningSynonyms); + } } } From f1e3bb44def70f63ba203c1a252dde2811050c20 Mon Sep 17 00:00:00 2001 From: Ratikant Singh Date: Tue, 15 Nov 2022 16:38:08 +0530 Subject: [PATCH 45/55] category reindexing issue when it is disable in one store --- Helper/Entity/CategoryHelper.php | 26 ++++++++++---------------- Helper/Entity/ProductHelper.php | 15 ++------------- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/Helper/Entity/CategoryHelper.php b/Helper/Entity/CategoryHelper.php index 9a7845a65..e2f030187 100755 --- a/Helper/Entity/CategoryHelper.php +++ b/Helper/Entity/CategoryHelper.php @@ -45,7 +45,6 @@ class CategoryHelper private $categoryRepository; private $isCategoryVisibleInMenuCache; - private $coreCategories; private $idColumn; private $categoryAttributes; private $rootCategoryId = -1; @@ -403,7 +402,6 @@ public function getCategoryName($categoryId, $storeId = null) $categoryId = (int) $categoryId; $storeId = (int) $storeId; - if (!isset($this->categoryNames)) { $this->categoryNames = []; @@ -434,7 +432,7 @@ public function getCategoryName($categoryId, $storeId = null) $categoryName = null; - $categoryKeyId = $this->getCategoryKeyId($categoryId); + $categoryKeyId = $this->getCategoryKeyId($categoryId, $storeId); if ($categoryKeyId === null) { return $categoryName; @@ -456,22 +454,21 @@ public function getCategoryName($categoryId, $storeId = null) return $categoryName; } - private function getCategoryKeyId($categoryId) + private function getCategoryKeyId($categoryId, $storeId = null) { $categoryKeyId = $categoryId; if ($this->getCorrectIdColumn() === 'row_id') { - $category = $this->getCategoryById($categoryId); - + $category = $this->getCategoryById($categoryId, $storeId); return $category ? $category->getRowId() : null; } return $categoryKeyId; } - private function getCategoryById($categoryId) + private function getCategoryById($categoryId, $storeId = null) { - $categories = $this->getCoreCategories(false); + $categories = $this->getCoreCategories(false, $storeId); return isset($categories[$categoryId]) ? $categories[$categoryId] : null; } @@ -492,16 +489,13 @@ public function isCategoryVisibleInMenu($categoryId, $storeId) return $this->isCategoryVisibleInMenuCache[$key]; } - public function getCoreCategories($filterNotIncludedCategories = true) + public function getCoreCategories($filterNotIncludedCategories = true, $storeId = null) { $key = $filterNotIncludedCategories ? 'filtered' : 'non_filtered'; - if (isset($this->coreCategories[$key])) { - return $this->coreCategories[$key]; - } - $collection = $this->categoryCollectionFactory->create() ->distinct(true) + ->setStoreId($storeId) ->addNameToResult() ->addIsActiveFilter() ->addAttributeToSelect('name') @@ -511,14 +505,14 @@ public function getCoreCategories($filterNotIncludedCategories = true) $collection->addAttributeToFilter('include_in_menu', '1'); } - $this->coreCategories[$key] = []; + $coreCategories[$key] = []; /** @var \Magento\Catalog\Model\Category $category */ foreach ($collection as $category) { - $this->coreCategories[$key][$category->getId()] = $category; + $coreCategories[$key][$category->getId()] = $category; } - return $this->coreCategories[$key]; + return $coreCategories[$key]; } private function getCorrectIdColumn() diff --git a/Helper/Entity/ProductHelper.php b/Helper/Entity/ProductHelper.php index d2ad78776..c2208547a 100755 --- a/Helper/Entity/ProductHelper.php +++ b/Helper/Entity/ProductHelper.php @@ -447,8 +447,8 @@ public function setSettings($indexName, $indexNameTmp, $storeId, $saveToTmpIndic public function getAllCategories($categoryIds, $storeId) { - $filterNotIncludedCategories = !$this->configHelper->showCatsNotIncludedInNavigation($storeId); - $categories = $this->categoryHelper->getCoreCategories($filterNotIncludedCategories); + $filterNotIncludedCategories = $this->configHelper->showCatsNotIncludedInNavigation($storeId); + $categories = $this->categoryHelper->getCoreCategories($filterNotIncludedCategories, $storeId); $selectedCategories = []; foreach ($categoryIds as $id) { @@ -501,30 +501,21 @@ public function getObject(Product $product) $customData = $this->addAttribute('ordered_qty', $defaultData, $customData, $additionalAttributes, $product); $customData = $this->addAttribute('total_ordered', $defaultData, $customData, $additionalAttributes, $product); $customData = $this->addAttribute('rating_summary', $defaultData, $customData, $additionalAttributes, $product); - $customData = $this->addCategoryData($customData, $product); $customData = $this->addImageData($customData, $product, $additionalAttributes); - $customData = $this->addInStock($defaultData, $customData, $product); $customData = $this->addStockQty($defaultData, $customData, $additionalAttributes, $product); - $subProducts = $this->getSubProducts($product); - $customData = $this->addAdditionalAttributes($customData, $additionalAttributes, $product, $subProducts); - $customData = $this->priceManager->addPriceDataByProductType($customData, $product, $subProducts); - $transport = new DataObject($customData); $this->eventManager->dispatch( 'algolia_subproducts_index', ['custom_data' => $transport, 'sub_products' => $subProducts, 'productObject' => $product] ); $customData = $transport->getData(); - $customData = array_merge($customData, $defaultData); - $this->algoliaHelper->castProductObject($customData); - $transport = new DataObject($customData); $this->eventManager->dispatch( 'algolia_after_create_product_object', @@ -621,7 +612,6 @@ private function addAttribute($attribute, $defaultData, $customData, $additional private function addCategoryData($customData, Product $product) { $storeId = $product->getStoreId(); - $categories = []; $categoriesWithPath = []; $categoryIds = []; @@ -645,7 +635,6 @@ private function addCategoryData($customData, Product $product) } $categoryName = $this->categoryHelper->getCategoryName($category->getId(), $storeId); - if ($categoryName) { $categories[] = $categoryName; } From af3cc2d51c52d0f95600740a5023cdb0966bfefd Mon Sep 17 00:00:00 2001 From: Ratikant Singh Date: Wed, 16 Nov 2022 15:07:38 +0530 Subject: [PATCH 46/55] resolve comment --- Helper/Entity/CategoryHelper.php | 92 ++++++++-- Helper/Entity/ProductHelper.php | 301 +++++++++++++++++++++++++++---- 2 files changed, 338 insertions(+), 55 deletions(-) diff --git a/Helper/Entity/CategoryHelper.php b/Helper/Entity/CategoryHelper.php index e2f030187..a31209153 100755 --- a/Helper/Entity/CategoryHelper.php +++ b/Helper/Entity/CategoryHelper.php @@ -22,35 +22,42 @@ class CategoryHelper { - private $eventManager; + /** @var ManagerInterface */ + protected $eventManager; - private $storeManager; + /** @var StoreManagerInterface */ + protected $storeManager; - private $resourceConnection; + /** @var ResourceConnection */ + protected $resourceConnection; - private $eavConfig; + /** @var Config */ + protected $eavConfig; - private $configHelper; + /** @var ConfigHelper */ + protected $configHelper; /** @var CategoryCollectionFactory */ - private $categoryCollectionFactory; + protected $categoryCollectionFactory; /** @var Image */ - private $imageHelper; + protected $imageHelper; /** @var CategoryResource */ - private $categoryResource; + protected $categoryResource; /** @var CategoryRepository */ - private $categoryRepository; + protected $categoryRepository; - private $isCategoryVisibleInMenuCache; - private $idColumn; - private $categoryAttributes; - private $rootCategoryId = -1; - private $activeCategories; - private $categoryNames; - private $moduleManager; + protected $isCategoryVisibleInMenuCache; + protected $idColumn; + protected $categoryAttributes; + protected $rootCategoryId = -1; + protected $activeCategories; + protected $categoryNames; + + /** @var Manager*/ + protected $moduleManager; /** * CategoryHelper constructor. @@ -89,11 +96,18 @@ public function __construct( $this->moduleManager = $moduleManager; } + /** + * @return string + */ public function getIndexNameSuffix() { return '_categories'; } + /** + * @param $storeId + * @return array|mixed|null + */ public function getIndexSettings($storeId) { $searchableAttributes = []; @@ -143,6 +157,10 @@ public function getIndexSettings($storeId) return $indexSettings; } + /** + * @param $storeId + * @return array + */ public function getAdditionalAttributes($storeId = null) { return $this->configHelper->getCategoryAdditionalAttributes($storeId); @@ -210,6 +228,10 @@ public function canCategoryBeReindexed($category, $storeId) return true; } + /** + * @return array + * @throws \Magento\Framework\Exception\LocalizedException + */ public function getAllAttributes() { if (isset($this->categoryAttributes)) { @@ -242,6 +264,11 @@ public function getAllAttributes() return $this->categoryAttributes; } + /** + * @param MagentoCategory $category + * @return array|mixed|null + * @throws \Magento\Framework\Exception\LocalizedException + */ public function getObject(Category $category) { /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */ @@ -326,6 +353,10 @@ public function getObject(Category $category) return $data; } + /** + * @return int|mixed + * @throws \Magento\Framework\Exception\LocalizedException + */ public function getRootCategoryId() { if ($this->rootCategoryId !== -1) { @@ -342,6 +373,10 @@ public function getRootCategoryId() return $this->rootCategoryId; } + /** + * @param MagentoCategory $category + * @return array|string|string[] + */ private function getUrl(Category $category) { $categoryUrl = $category->getUrl(); @@ -454,6 +489,11 @@ public function getCategoryName($categoryId, $storeId = null) return $categoryName; } + /** + * @param $categoryId + * @param $storeId + * @return mixed|null + */ private function getCategoryKeyId($categoryId, $storeId = null) { $categoryKeyId = $categoryId; @@ -466,6 +506,11 @@ private function getCategoryKeyId($categoryId, $storeId = null) return $categoryKeyId; } + /** + * @param $categoryId + * @param $storeId + * @return mixed|null + */ private function getCategoryById($categoryId, $storeId = null) { $categories = $this->getCoreCategories(false, $storeId); @@ -473,6 +518,12 @@ private function getCategoryById($categoryId, $storeId = null) return isset($categories[$categoryId]) ? $categories[$categoryId] : null; } + /** + * @param $categoryId + * @param $storeId + * @return bool|mixed + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ public function isCategoryVisibleInMenu($categoryId, $storeId) { $key = $categoryId . '-' . $storeId; @@ -489,6 +540,12 @@ public function isCategoryVisibleInMenu($categoryId, $storeId) return $this->isCategoryVisibleInMenuCache[$key]; } + /** + * @param $filterNotIncludedCategories + * @param $storeId + * @return array + * @throws \Magento\Framework\Exception\LocalizedException + */ public function getCoreCategories($filterNotIncludedCategories = true, $storeId = null) { $key = $filterNotIncludedCategories ? 'filtered' : 'non_filtered'; @@ -515,6 +572,9 @@ public function getCoreCategories($filterNotIncludedCategories = true, $storeId return $coreCategories[$key]; } + /** + * @return string + */ private function getCorrectIdColumn() { if (isset($this->idColumn)) { diff --git a/Helper/Entity/ProductHelper.php b/Helper/Entity/ProductHelper.php index c2208547a..276cd7a9a 100755 --- a/Helper/Entity/ProductHelper.php +++ b/Helper/Entity/ProductHelper.php @@ -35,35 +35,86 @@ class ProductHelper { + /** + * @var CollectionFactory + */ protected $productCollectionFactory; + /** + * @var GroupCollection + */ protected $groupCollection; - private $eavConfig; - private $configHelper; - private $algoliaHelper; - private $logger; - private $storeManager; - private $eventManager; - private $visibility; - private $stockHelper; - private $stockRegistry; - private $currencyManager; - private $categoryHelper; - private $priceManager; - private $imageHelper; + /** + * @var Config + */ + protected $eavConfig; + /** + * @var ConfigHelper + */ + protected $configHelper; + /** + * @var AlgoliaHelper + */ + protected $algoliaHelper; + /** + * @var Logger + */ + protected $logger; + /** + * @var StoreManagerInterface + */ + protected $storeManager; + /** + * @var ManagerInterface + */ + protected $eventManager; + /** + * @var Visibility + */ + protected $visibility; + /** + * @var Stock + */ + protected $stockHelper; + /** + * @var StockRegistryInterface + */ + protected $stockRegistry; + /** + * @var CurrencyHelper + */ + protected $currencyManager; + /** + * @var CategoryHelper + */ + protected $categoryHelper; + /** + * @var PriceManager + */ + protected $priceManager; + /** + * @var ImageHelper + */ + protected $imageHelper; /** * @var Type */ - private $productType; + protected $productType; /** * @var AbstractType[] */ - private $compositeTypes; + protected $compositeTypes; - private $productAttributes; + /** + * @var + */ + protected $productAttributes; - private $predefinedProductAttributes = [ + /** + * @var string[] + */ + protected $predefinedProductAttributes = [ 'name', 'url_key', 'image', @@ -72,7 +123,10 @@ class ProductHelper 'msrp_enabled', // Needed to handle MSRP behavior ]; - private $createdAttributes = [ + /** + * @var string[] + */ + protected $createdAttributes = [ 'path', 'categories', 'categories_without_path', @@ -84,7 +138,10 @@ class ProductHelper 'in_stock', ]; - private $attributesToIndexAsArray = [ + /** + * @var string[] + */ + protected $attributesToIndexAsArray = [ 'sku', 'color', ]; @@ -145,11 +202,19 @@ public function __construct( $this->imageHelper = $imageHelper; } + /** + * @return string + */ public function getIndexNameSuffix() { return '_products'; } + /** + * @param $addEmptyRow + * @return array + * @throws \Magento\Framework\Exception\LocalizedException + */ public function getAllAttributes($addEmptyRow = false) { if (!isset($this->productAttributes)) { @@ -202,6 +267,11 @@ public function getAllAttributes($addEmptyRow = false) return $attributes; } + /** + * @param $additionalAttributes + * @param $attributeName + * @return bool + */ public function isAttributeEnabled($additionalAttributes, $attributeName) { foreach ($additionalAttributes as $attr) { @@ -213,6 +283,13 @@ public function isAttributeEnabled($additionalAttributes, $attributeName) return false; } + /** + * @param $storeId + * @param $productIds + * @param $onlyVisible + * @param $includeNotVisibleIndividually + * @return \Magento\Catalog\Model\ResourceModel\Product\Collection + */ public function getProductCollectionQuery( $storeId, $productIds = null, @@ -272,6 +349,11 @@ public function getProductCollectionQuery( return $products; } + /** + * @param $products + * @param $storeId + * @return void + */ protected function addStockFilter($products, $storeId) { if ($this->configHelper->getShowOutOfStock($storeId) === false) { @@ -279,6 +361,10 @@ protected function addStockFilter($products, $storeId) } } + /** + * @param $products + * @return void + */ protected function addMandatoryAttributes($products) { /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $products */ @@ -290,11 +376,23 @@ protected function addMandatoryAttributes($products) ->addAttributeToSelect('status'); } + /** + * @param $storeId + * @return array + */ public function getAdditionalAttributes($storeId = null) { return $this->configHelper->getProductAdditionalAttributes($storeId); } + /** + * @param $indexName + * @param $indexNameTmp + * @param $storeId + * @param $saveToTmpIndicesToo + * @return void + * @throws AlgoliaException + */ public function setSettings($indexName, $indexNameTmp, $storeId, $saveToTmpIndicesToo = false) { $searchableAttributes = $this->getSearchableAttributes($storeId); @@ -445,6 +543,12 @@ public function setSettings($indexName, $indexNameTmp, $storeId, $saveToTmpIndic } } + /** + * @param $categoryIds + * @param $storeId + * @return array + * @throws \Magento\Framework\Exception\LocalizedException + */ public function getAllCategories($categoryIds, $storeId) { $filterNotIncludedCategories = $this->configHelper->showCatsNotIncludedInNavigation($storeId); @@ -460,6 +564,11 @@ public function getAllCategories($categoryIds, $storeId) return $selectedCategories; } + /** + * @param Product $product + * @return array|mixed|null + * @throws \Exception + */ public function getObject(Product $product) { $storeId = $product->getStoreId(); @@ -528,7 +637,11 @@ public function getObject(Product $product) return $customData; } - private function getSubProducts(Product $product) + /** + * @param Product $product + * @return array|\Magento\Catalog\Api\Data\ProductInterface[]|DataObject[] + */ + protected function getSubProducts(Product $product) { $type = $product->getTypeId(); @@ -586,7 +699,7 @@ public function getParentProductIds(array $productIds) * * @see \Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction::_getProductTypeInstances */ - private function getCompositeTypes() + protected function getCompositeTypes() { if ($this->compositeTypes === null) { $productEmulator = new \Magento\Framework\DataObject(); @@ -599,7 +712,15 @@ private function getCompositeTypes() return $this->compositeTypes; } - private function addAttribute($attribute, $defaultData, $customData, $additionalAttributes, Product $product) + /** + * @param $attribute + * @param $defaultData + * @param $customData + * @param $additionalAttributes + * @param Product $product + * @return mixed + */ + protected function addAttribute($attribute, $defaultData, $customData, $additionalAttributes, Product $product) { if (isset($defaultData[$attribute]) === false && $this->isAttributeEnabled($additionalAttributes, $attribute)) { @@ -609,7 +730,14 @@ private function addAttribute($attribute, $defaultData, $customData, $additional return $customData; } - private function addCategoryData($customData, Product $product) + /** + * @param $customData + * @param Product $product + * @return mixed + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + protected function addCategoryData($customData, Product $product) { $storeId = $product->getStoreId(); $categories = []; @@ -674,7 +802,11 @@ private function addCategoryData($customData, Product $product) return $customData; } - private function getHierarchicalCategories($categoriesWithPath) + /** + * @param $categoriesWithPath + * @return array + */ + protected function getHierarchicalCategories($categoriesWithPath) { $hierachivalCategories = []; @@ -702,7 +834,13 @@ private function getHierarchicalCategories($categoriesWithPath) return $hierachivalCategories; } - private function addImageData(array $customData, Product $product, $additionalAttributes) + /** + * @param array $customData + * @param Product $product + * @param $additionalAttributes + * @return array + */ + protected function addImageData(array $customData, Product $product, $additionalAttributes) { if (false === isset($customData['thumbnail_url'])) { $customData['thumbnail_url'] = $this->imageHelper @@ -734,6 +872,12 @@ private function addImageData(array $customData, Product $product, $additionalAt return $customData; } + /** + * @param $defaultData + * @param $customData + * @param Product $product + * @return mixed + */ protected function addInStock($defaultData, $customData, Product $product) { if (isset($defaultData['in_stock']) === false) { @@ -744,7 +888,14 @@ protected function addInStock($defaultData, $customData, Product $product) return $customData; } - private function addStockQty($defaultData, $customData, $additionalAttributes, Product $product) + /** + * @param $defaultData + * @param $customData + * @param $additionalAttributes + * @param Product $product + * @return mixed + */ + protected function addStockQty($defaultData, $customData, $additionalAttributes, Product $product) { if (isset($defaultData['stock_qty']) === false && $this->isAttributeEnabled($additionalAttributes, 'stock_qty')) { @@ -759,7 +910,15 @@ private function addStockQty($defaultData, $customData, $additionalAttributes, P return $customData; } - private function addAdditionalAttributes($customData, $additionalAttributes, Product $product, $subProducts) + /** + * @param $customData + * @param $additionalAttributes + * @param Product $product + * @param $subProducts + * @return mixed + * @throws \Magento\Framework\Exception\LocalizedException + */ + protected function addAdditionalAttributes($customData, $additionalAttributes, Product $product, $subProducts) { foreach ($additionalAttributes as $attribute) { $attributeName = $attribute['attribute']; @@ -800,7 +959,14 @@ private function addAdditionalAttributes($customData, $additionalAttributes, Pro return $customData; } - private function addNullValue($customData, $subProducts, $attribute, AttributeResource $attributeResource) + /** + * @param $customData + * @param $subProducts + * @param $attribute + * @param AttributeResource $attributeResource + * @return mixed + */ + protected function addNullValue($customData, $subProducts, $attribute, AttributeResource $attributeResource) { $attributeName = $attribute['attribute']; @@ -841,7 +1007,13 @@ private function addNullValue($customData, $subProducts, $attribute, AttributeRe return $customData; } - private function getValues($valueText, Product $subProduct, AttributeResource $attributeResource) + /** + * @param $valueText + * @param Product $subProduct + * @param AttributeResource $attributeResource + * @return array + */ + protected function getValues($valueText, Product $subProduct, AttributeResource $attributeResource) { $values = []; @@ -860,7 +1032,14 @@ private function getValues($valueText, Product $subProduct, AttributeResource $a return $values; } - private function addSubProductImage($subProductImages, $attribute, $subProduct, $valueText) + /** + * @param $subProductImages + * @param $attribute + * @param $subProduct + * @param $valueText + * @return mixed + */ + protected function addSubProductImage($subProductImages, $attribute, $subProduct, $valueText) { if (mb_strtolower($attribute['attribute'], 'utf-8') !== 'color') { return $subProductImages; @@ -889,7 +1068,15 @@ private function addSubProductImage($subProductImages, $attribute, $subProduct, return $subProductImages; } - private function addNonNullValue( + /** + * @param $customData + * @param $value + * @param Product $product + * @param $attribute + * @param AttributeResource $attributeResource + * @return mixed + */ + protected function addNonNullValue( $customData, $value, Product $product, @@ -916,7 +1103,11 @@ private function addNonNullValue( return $customData; } - private function getSearchableAttributes($storeId = null) + /** + * @param $storeId + * @return array + */ + protected function getSearchableAttributes($storeId = null) { $searchableAttributes = []; @@ -940,7 +1131,11 @@ private function getSearchableAttributes($storeId = null) return $searchableAttributes; } - private function getCustomRanking($storeId) + /** + * @param $storeId + * @return array + */ + protected function getCustomRanking($storeId) { $customRanking = []; @@ -952,7 +1147,11 @@ private function getCustomRanking($storeId) return $customRanking; } - private function getUnretrieveableAttributes($storeId = null) + /** + * @param $storeId + * @return array + */ + protected function getUnretrieveableAttributes($storeId = null) { $unretrievableAttributes = []; @@ -965,7 +1164,11 @@ private function getUnretrieveableAttributes($storeId = null) return $unretrievableAttributes; } - private function getAttributesForFaceting($storeId) + /** + * @param $storeId + * @return array + */ + protected function getAttributesForFaceting($storeId) { $attributesForFaceting = []; @@ -1011,7 +1214,13 @@ private function getAttributesForFaceting($storeId) return $attributesForFaceting; } - private function deleteUnusedReplicas($indexName, $replicas, $setReplicasTaskId) + /** + * @param $indexName + * @param $replicas + * @param $setReplicasTaskId + * @return void + */ + protected function deleteUnusedReplicas($indexName, $replicas, $setReplicasTaskId) { $indicesToDelete = []; @@ -1035,7 +1244,12 @@ private function deleteUnusedReplicas($indexName, $replicas, $setReplicasTaskId) } } - private function setFacetsQueryRules($indexName) + /** + * @param $indexName + * @return void + * @throws AlgoliaException + */ + protected function setFacetsQueryRules($indexName) { $index = $this->algoliaHelper->getIndex($indexName); @@ -1079,7 +1293,12 @@ private function setFacetsQueryRules($indexName) } } - private function clearFacetsQueryRules(SearchIndex $index) + /** + * @param SearchIndex $index + * @return void + * @throws AlgoliaException + */ + protected function clearFacetsQueryRules(SearchIndex $index) { try { $hitsPerPage = 100; @@ -1112,7 +1331,11 @@ private function clearFacetsQueryRules(SearchIndex $index) } } - private function explodeSynonyms($synonyms) + /** + * @param $synonyms + * @return array + */ + protected function explodeSynonyms($synonyms) { return array_map('trim', explode(',', $synonyms)); } From bed9fe58722b1046c295c1e83d002a117cf8922c Mon Sep 17 00:00:00 2001 From: Ratikant Singh Date: Wed, 16 Nov 2022 22:47:03 +0530 Subject: [PATCH 47/55] MAGE-499 Max retries for queue fixes --- Model/Queue.php | 101 ++++++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 46 deletions(-) diff --git a/Model/Queue.php b/Model/Queue.php index a480ad960..1aec3a767 100644 --- a/Model/Queue.php +++ b/Model/Queue.php @@ -25,50 +25,58 @@ class Queue public const ERROR_LOG = 'algoliasearch_queue_errors.log'; /** @var AdapterInterface */ - private $db; + protected $db; /** @var string */ - private $table; + protected $table; /** @var string */ - private $logTable; + protected $logTable; /** @var string */ - private $archiveTable; + protected $archiveTable; /** @var ObjectManagerInterface */ - private $objectManager; + protected $objectManager; /** @var ConsoleOutput */ - private $output; + protected $output; /** @var int */ - private $elementsPerPage; + protected $elementsPerPage; /** @var ConfigHelper */ - private $configHelper; + protected $configHelper; /** @var Logger */ - private $logger; + protected $logger; - private $jobCollectionFactory; + protected $jobCollectionFactory; /** @var int */ - private $maxSingleJobDataSize; + protected $maxSingleJobDataSize; /** @var int */ - private $noOfFailedJobs = 0; + protected $noOfFailedJobs = 0; /** @var array */ - private $staticJobMethods = [ + protected $staticJobMethods = [ 'saveConfigurationToAlgolia', 'moveIndexWithSetSettings', 'deleteObjects', ]; /** @var array */ - private $logRecord; + protected $logRecord; + /** + * @param ConfigHelper $configHelper + * @param Logger $logger + * @param JobCollectionFactory $jobCollectionFactory + * @param ResourceConnection $resourceConnection + * @param ObjectManagerInterface $objectManager + * @param ConsoleOutput $output + */ public function __construct( ConfigHelper $configHelper, Logger $logger, @@ -117,6 +125,7 @@ public function addToQueue($className, $method, array $data, $dataSize = 1, $isF 'data' => json_encode($data), 'data_size' => $dataSize, 'pid' => null, + 'max_retries' => $this->configHelper->getRetryLimit(), 'is_full_reindex' => $isFullReindex ? 1 : 0, ]); } else { @@ -136,8 +145,8 @@ public function addToQueue($className, $method, array $data, $dataSize = 1, $isF public function getAverageProcessingTime() { $select = $this->db->select() - ->from($this->logTable, ['number_of_runs' => 'COUNT(duration)', 'average_time' => 'AVG(duration)']) - ->where('processed_jobs > 0 AND with_empty_queue = 0 AND started >= (CURDATE() - INTERVAL 2 DAY)'); + ->from($this->logTable, ['number_of_runs' => 'COUNT(duration)', 'average_time' => 'AVG(duration)']) + ->where('processed_jobs > 0 AND with_empty_queue = 0 AND started >= (CURDATE() - INTERVAL 2 DAY)'); $data = $this->db->query($select)->fetch(); @@ -264,11 +273,11 @@ public function run($maxJobs) /** * @param string $whereClause */ - private function archiveFailedJobs($whereClause) + protected function archiveFailedJobs($whereClause) { $select = $this->db->select() - ->from($this->table, ['pid', 'class', 'method', 'data', 'error_log', 'data_size', 'NOW()']) - ->where($whereClause); + ->from($this->table, ['pid', 'class', 'method', 'data', 'error_log', 'data_size', 'NOW()']) + ->where($whereClause); $query = $this->db->insertFromSelect( $select, @@ -287,7 +296,7 @@ private function archiveFailedJobs($whereClause) * @return Job[] * */ - private function getJobs($maxJobs) + protected function getJobs($maxJobs) { $maxJobs = ($maxJobs === -1) ? $this->configHelper->getNumberOfJobToRun() : $maxJobs; @@ -334,7 +343,7 @@ private function getJobs($maxJobs) * * @return Job[] */ - private function fetchJobs($jobsLimit, $fetchFullReindexJobs = false, $lastJobId = null) + protected function fetchJobs($jobsLimit, $fetchFullReindexJobs = false, $lastJobId = null) { $jobs = []; @@ -353,8 +362,8 @@ private function fetchJobs($jobsLimit, $fetchFullReindexJobs = false, $lastJobId ->addFieldToFilter('is_full_reindex', $fetchFullReindexJobs) ->setOrder('job_id', Collection::SORT_ORDER_ASC) ->getSelect() - ->limit($limit, $offset) - ->forUpdate(); + ->limit($limit, $offset) + ->forUpdate(); if ($lastJobId !== null) { $jobsCollection->addFieldToFilter('job_id', ['gt' => $lastJobId]); @@ -404,7 +413,7 @@ private function fetchJobs($jobsLimit, $fetchFullReindexJobs = false, $lastJobId * * @return Job[] */ - private function mergeJobs(array $unmergedJobs) + protected function mergeJobs(array $unmergedJobs) { $unmergedJobs = $this->sortJobs($unmergedJobs); @@ -441,7 +450,7 @@ private function mergeJobs(array $unmergedJobs) * * @return Job[] */ - private function sortJobs(array $jobs) + protected function sortJobs(array $jobs) { $sortedJobs = []; @@ -473,7 +482,7 @@ private function sortJobs(array $jobs) * * @return array */ - private function stackSortedJobs(array $sortedJobs, array $tempSortableJobs, Job $job = null) + protected function stackSortedJobs(array $sortedJobs, array $tempSortableJobs, Job $job = null) { if ($tempSortableJobs && $tempSortableJobs !== []) { $tempSortableJobs = $this->jobSort( @@ -501,7 +510,7 @@ private function stackSortedJobs(array $sortedJobs, array $tempSortableJobs, Job /** * @return array */ - private function jobSort() + protected function jobSort() { $args = func_get_args(); @@ -533,7 +542,7 @@ private function jobSort() /** * @param Job[] $jobs */ - private function lockJobs(array $jobs) + protected function lockJobs(array $jobs) { $jobsIds = $this->getJobsIdsFromMergedJobs($jobs); @@ -551,7 +560,7 @@ private function lockJobs(array $jobs) * * @return string[] */ - private function getJobsIdsFromMergedJobs(array $mergedJobs) + protected function getJobsIdsFromMergedJobs(array $mergedJobs) { $jobsIds = []; foreach ($mergedJobs as $job) { @@ -561,17 +570,11 @@ private function getJobsIdsFromMergedJobs(array $mergedJobs) return $jobsIds; } - private function clearOldFailingJobs() + /** + * @return void + */ + protected function clearOldFailingJobs() { - $retryLimit = $this->configHelper->getRetryLimit(); - - if ($retryLimit > 0) { - $where = $this->db->quoteInto('retries >= ?', $retryLimit); - $this->archiveFailedJobs($where); - - return; - } - $this->archiveFailedJobs('retries > max_retries'); $this->db->delete($this->table, 'retries > max_retries'); } @@ -579,12 +582,12 @@ private function clearOldFailingJobs() /** * @throws Zend_Db_Statement_Exception */ - private function clearOldLogRecords() + protected function clearOldLogRecords() { $select = $this->db->select() - ->from($this->logTable, ['id']) - ->order(['started DESC', 'id DESC']) - ->limit(PHP_INT_MAX, 25000); + ->from($this->logTable, ['id']) + ->order(['started DESC', 'id DESC']) + ->limit(PHP_INT_MAX, 25000); $idsToDelete = $this->db->query($select)->fetchAll(PDO::FETCH_COLUMN, 0); @@ -593,7 +596,10 @@ private function clearOldLogRecords() } } - private function clearOldArchiveRecords() + /** + * @return void + */ + protected function clearOldArchiveRecords() { $archiveLogClearLimit = $this->configHelper->getArchiveLogClearLimit(); // Adding a fallback in case this configuration was not set in a consistent way @@ -607,7 +613,10 @@ private function clearOldArchiveRecords() ); } - private function unlockStackedJobs() + /** + * @return void + */ + protected function unlockStackedJobs() { $this->db->update($this->table, [ 'locked_at' => null, @@ -618,7 +627,7 @@ private function unlockStackedJobs() /** * @return bool */ - private function shouldEmptyQueue() + protected function shouldEmptyQueue() { if (getenv('PROCESS_FULL_QUEUE') && getenv('PROCESS_FULL_QUEUE') === '1') { return true; From 0d15def2131882cabc334ad84521c1e0de01b152 Mon Sep 17 00:00:00 2001 From: rachel-trott <105296912+rachel-trott@users.noreply.github.com> Date: Fri, 18 Nov 2022 15:06:39 -0600 Subject: [PATCH 48/55] typo fix --- view/adminhtml/web/js/config.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/view/adminhtml/web/js/config.js b/view/adminhtml/web/js/config.js index ee44d7b25..6e55634bf 100644 --- a/view/adminhtml/web/js/config.js +++ b/view/adminhtml/web/js/config.js @@ -34,11 +34,12 @@ require( ]; var pageWarning = '
'; - pageWarning += '

These settings are also available in the Algolia Dashboard. We advise you to manage it from this page, because saving Magento settings will override the Algolia settings.

'; + pageWarning += '

These settings are also available in the Algolia Dashboard. We advise you to manage it from this page, + cause saving Magento settings will override the Algolia settings.

'; pageWarning += '
'; var pageWarningSynonyms = '
'; - pageWarningSynonyms += '

These settings are also available in the Algolia Dashboard. We advise you to configure synonyms configuration from the Algolia dashboard as this is going to be be deprecated in release 3.9.2.

'; + pageWarningSynonyms += '

These settings are also available in the Algolia Dashboard. We advise you to configure synonyms configuration from the Algolia dashboard as this is going to be deprecated in release 3.9.2.

'; pageWarningSynonyms += '
'; for (var i=0; i < pageIds.length; i++) { From da9c661f4b24c1a8c3f5f36e33523c5bd0b52f7d Mon Sep 17 00:00:00 2001 From: Mohit Choudhary Date: Tue, 22 Nov 2022 17:06:31 +0530 Subject: [PATCH 49/55] Fixed Code formating --- view/adminhtml/web/js/config.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/view/adminhtml/web/js/config.js b/view/adminhtml/web/js/config.js index 6e55634bf..70096033e 100644 --- a/view/adminhtml/web/js/config.js +++ b/view/adminhtml/web/js/config.js @@ -34,8 +34,7 @@ require( ]; var pageWarning = '
'; - pageWarning += '

These settings are also available in the Algolia Dashboard. We advise you to manage it from this page, - cause saving Magento settings will override the Algolia settings.

'; + pageWarning += '

These settings are also available in the Algolia Dashboard. We advise you to manage it from this page, cause saving Magento settings will override the Algolia settings.

'; pageWarning += '
'; var pageWarningSynonyms = '
'; From f08d2159f46d9168daad5840a1a67fd6878f3a47 Mon Sep 17 00:00:00 2001 From: Mohit Choudhary Date: Tue, 22 Nov 2022 19:26:29 +0530 Subject: [PATCH 50/55] Fixed php-cs Fixer issues --- Block/Algolia.php | 129 +++++++++++++++++++++++------ Block/Configuration.php | 22 ++--- Helper/ConfigHelper.php | 29 +------ Helper/Entity/SuggestionHelper.php | 69 ++++++++++----- 4 files changed, 164 insertions(+), 85 deletions(-) diff --git a/Block/Algolia.php b/Block/Algolia.php index bc50969ef..8ed8f8c88 100755 --- a/Block/Algolia.php +++ b/Block/Algolia.php @@ -8,7 +8,9 @@ use Algolia\AlgoliaSearch\Helper\Data as CoreHelper; use Algolia\AlgoliaSearch\Helper\Entity\CategoryHelper; use Algolia\AlgoliaSearch\Helper\Entity\ProductHelper; +use Algolia\AlgoliaSearch\Helper\Entity\SuggestionHelper; use Algolia\AlgoliaSearch\Helper\LandingPageHelper; +use Magento\Catalog\Model\Product; use Magento\Checkout\Model\Session as CheckoutSession; use Magento\Customer\Model\Context as CustomerContext; use Magento\Framework\App\ActionInterface; @@ -21,29 +23,103 @@ use Magento\Framework\Stdlib\DateTime\DateTime; use Magento\Framework\Url\Helper\Data; use Magento\Framework\View\Element\Template; +use Magento\Sales\Model\Order; use Magento\Search\Helper\Data as CatalogSearchHelper; class Algolia extends Template implements CollectionDataSourceInterface { - private $config; - private $catalogSearchHelper; - private $registry; - private $productHelper; - private $currency; - private $format; - private $algoliaHelper; - private $urlHelper; - private $formKey; - private $httpContext; - private $coreHelper; - private $categoryHelper; - private $landingPageHelper; - private $personalizationHelper; - private $checkoutSession; - private $date; - - private $priceKey; + /** + * @var ConfigHelper + */ + protected $config; + /** + * @var CatalogSearchHelper + */ + protected $catalogSearchHelper; + /** + * @var Registry + */ + protected $registry; + /** + * @var ProductHelper + */ + protected $productHelper; + /** + * @var Currency + */ + protected $currency; + /** + * @var Format + */ + protected $format; + /** + * @var AlgoliaHelper + */ + protected $algoliaHelper; + /** + * @var Data + */ + protected $urlHelper; + /** + * @var FormKey + */ + protected $formKey; + /** + * @var HttpContext + */ + protected $httpContext; + /** + * @var CoreHelper + */ + protected $coreHelper; + /** + * @var CategoryHelper + */ + protected $categoryHelper; + /** + * @var SuggestionHelper + */ + protected $suggestionHelper; + /** + * @var LandingPageHelper + */ + protected $landingPageHelper; + /** + * @var PersonalizationHelper + */ + protected $personalizationHelper; + /** + * @var CheckoutSession + */ + protected $checkoutSession; + /** + * @var DateTime + */ + protected $date; + + protected $priceKey; + /** + * @param Template\Context $context + * @param ConfigHelper $config + * @param CatalogSearchHelper $catalogSearchHelper + * @param ProductHelper $productHelper + * @param Currency $currency + * @param Format $format + * @param Registry $registry + * @param AlgoliaHelper $algoliaHelper + * @param Data $urlHelper + * @param FormKey $formKey + * @param HttpContext $httpContext + * @param CoreHelper $coreHelper + * @param CategoryHelper $categoryHelper + * @param SuggestionHelper $suggestionHelper + * @param LandingPageHelper $landingPageHelper + * @param PersonalizationHelper $personalizationHelper + * @param CheckoutSession $checkoutSession + * @param DateTime $date + * @param array $data + */ public function __construct( Template\Context $context, ConfigHelper $config, @@ -58,6 +134,7 @@ public function __construct( HttpContext $httpContext, CoreHelper $coreHelper, CategoryHelper $categoryHelper, + SuggestionHelper $suggestionHelper, LandingPageHelper $landingPageHelper, PersonalizationHelper $personalizationHelper, CheckoutSession $checkoutSession, @@ -76,6 +153,7 @@ public function __construct( $this->httpContext = $httpContext; $this->coreHelper = $coreHelper; $this->categoryHelper = $categoryHelper; + $this->suggestionHelper = $suggestionHelper; $this->landingPageHelper = $landingPageHelper; $this->personalizationHelper = $personalizationHelper; $this->checkoutSession = $checkoutSession; @@ -115,6 +193,11 @@ public function getCategoryHelper() return $this->categoryHelper; } + public function getSuggestionHelper() + { + return $this->suggestionHelper; + } + public function getCatalogSearchHelper() { return $this->catalogSearchHelper; @@ -175,13 +258,13 @@ public function getCurrentCategory() return $this->registry->registry('current_category'); } - /** @return \Magento\Catalog\Model\Product */ + /** @return Product */ public function getCurrentProduct() { return $this->registry->registry('product'); } - /** @return \Magento\Sales\Model\Order */ + /** @return Order */ public function getLastOrder() { return $this->checkoutSession->getLastRealOrder(); @@ -202,20 +285,17 @@ public function getTimestamp() return $this->date->gmtTimestamp('today midnight'); } - private function getAddToCartUrl($additional = []) + protected function getAddToCartUrl($additional = []) { $continueUrl = $this->urlHelper->getEncodedUrl($this->_urlBuilder->getCurrentUrl()); $urlParamName = ActionInterface::PARAM_NAME_URL_ENCODED; - $routeParams = [ $urlParamName => $continueUrl, '_secure' => $this->algoliaHelper->getRequest()->isSecure(), ]; - if ($additional !== []) { $routeParams = array_merge($routeParams, $additional); } - return $this->_urlBuilder->getUrl('checkout/cart/add', $routeParams); } @@ -225,7 +305,6 @@ protected function getCurrentLandingPage() if (!$landingPageId) { return null; } - return $this->landingPageHelper->getLandingPage($landingPageId); } } diff --git a/Block/Configuration.php b/Block/Configuration.php index 61d1cbd39..64018dd76 100755 --- a/Block/Configuration.php +++ b/Block/Configuration.php @@ -40,6 +40,8 @@ public function getConfiguration() $categoryHelper = $this->getCategoryHelper(); + $suggestionHelper = $this->getSuggestionHelper(); + $productHelper = $this->getProductHelper(); $algoliaHelper = $this->getAlgoliaHelper(); @@ -225,7 +227,7 @@ public function getConfiguration() 'showCatsNotIncludedInNavigation' => $config->showCatsNotIncludedInNavigation(), 'showSuggestionsOnNoResultsPage' => $config->showSuggestionsOnNoResultsPage(), 'baseUrl' => $baseUrl, - 'popularQueries' => $config->getPopularQueries(), + 'popularQueries' => $suggestionHelper->getPopularQueries(), 'useAdaptiveImage' => $config->useAdaptiveImage(), 'urls' => [ 'logo' => $this->getViewFileUrl('Algolia_AlgoliaSearch::images/search-by-algolia.svg'), @@ -305,17 +307,15 @@ public function getConfiguration() $transport = new DataObject($algoliaJsConfig); $this->_eventManager->dispatch('algolia_after_create_configuration', ['configuration' => $transport]); - $algoliaJsConfig = $transport->getData(); - - return $algoliaJsConfig; + return $transport->getData(); } - private function areCategoriesInFacets($facets) + protected function areCategoriesInFacets($facets) { return in_array('categories', array_column($facets, 'attribute')); } - private function getUrlTrackedParameters() + protected function getUrlTrackedParameters() { $urlTrackedParameters = ['query', 'attribute:*', 'index']; @@ -326,7 +326,7 @@ private function getUrlTrackedParameters() return $urlTrackedParameters; } - private function getOrderedProductIds(ConfigHelper $configHelper, Http $request) + protected function getOrderedProductIds(ConfigHelper $configHelper, Http $request) { $ids = []; @@ -349,22 +349,22 @@ private function getOrderedProductIds(ConfigHelper $configHelper, Http $request) return $ids; } - private function isLandingPage() + protected function isLandingPage() { return $this->getRequest()->getFullActionName() === 'algolia_landingpage_view'; } - private function getLandingPageId() + protected function getLandingPageId() { return $this->isLandingPage() ? $this->getCurrentLandingPage()->getId() : ''; } - private function getLandingPageQuery() + protected function getLandingPageQuery() { return $this->isLandingPage() ? $this->getCurrentLandingPage()->getQuery() : ''; } - private function getLandingPageConfiguration() + protected function getLandingPageConfiguration() { return $this->isLandingPage() ? $this->getCurrentLandingPage()->getConfiguration() : json_encode([]); } diff --git a/Helper/ConfigHelper.php b/Helper/ConfigHelper.php index 798cb127c..a2ae580bb 100755 --- a/Helper/ConfigHelper.php +++ b/Helper/ConfigHelper.php @@ -2,7 +2,6 @@ namespace Algolia\AlgoliaSearch\Helper; -use Algolia\AlgoliaSearch\Helper\Entity\SuggestionHelper; use Magento; use Magento\Customer\Model\ResourceModel\Group\Collection as GroupCollection; use Magento\Directory\Model\Currency as DirCurrency; @@ -175,10 +174,6 @@ class ConfigHelper */ protected $groupCollection; - /** - * @var SuggestionHelper - */ - protected $suggestionHelper; /** * @param Magento\Framework\App\Config\ScopeConfigInterface $configInterface @@ -191,7 +186,6 @@ class ConfigHelper * @param Magento\Framework\Event\ManagerInterface $eventManager * @param SerializerInterface $serializer * @param GroupCollection $groupCollection - * @param SuggestionHelper $suggestionHelper */ public function __construct( Magento\Framework\App\Config\ScopeConfigInterface $configInterface, @@ -203,8 +197,7 @@ public function __construct( Magento\Framework\App\ProductMetadataInterface $productMetadata, Magento\Framework\Event\ManagerInterface $eventManager, SerializerInterface $serializer, - GroupCollection $groupCollection, - SuggestionHelper $suggestionHelper + GroupCollection $groupCollection ) { $this->configInterface = $configInterface; $this->currency = $currency; @@ -216,7 +209,6 @@ public function __construct( $this->eventManager = $eventManager; $this->serializer = $serializer; $this->groupCollection = $groupCollection; - $this->suggestionHelper = $suggestionHelper; } /** @@ -1239,23 +1231,6 @@ public function getCurrency($storeId = null) return $this->currency->getCurrency($store->getCurrentCurrencyCode())->getSymbol(); } - /** - * @param $storeId - * @return array|bool|float|int|string|null - * @throws Magento\Framework\Exception\NoSuchEntityException - */ - public function getPopularQueries($storeId = null) - { - if (!$this->isInstantEnabled($storeId) || !$this->showSuggestionsOnNoResultsPage($storeId)) { - return []; - } - if ($storeId === null) { - $storeId = $this->storeManager->getStore()->getId(); - } - $suggestionHelper = $this->suggestionHelper; - return $suggestionHelper->getPopularQueries($storeId); - } - /** * @param $storeId * @return bool @@ -1624,4 +1599,4 @@ public function getArchiveLogClearLimit($storeId = null) $storeId ); } -} +} \ No newline at end of file diff --git a/Helper/Entity/SuggestionHelper.php b/Helper/Entity/SuggestionHelper.php index 581d6510b..ebdcaf418 100755 --- a/Helper/Entity/SuggestionHelper.php +++ b/Helper/Entity/SuggestionHelper.php @@ -12,20 +12,29 @@ class SuggestionHelper { - private $eventManager; + /** + * @var ManagerInterface + */ + protected $eventManager; /** * @var QueryCollectionFactory */ - private $queryCollectionFactory; - - private $cache; - - private $configHelper; - - private $serializer; + protected $queryCollectionFactory; + /** + * @var ConfigCache + */ + protected $cache; + /** + * @var ConfigHelper + */ + protected $configHelper; + /** + * @var SerializerInterface + */ + protected $serializer; - private $popularQueriesCacheId = 'algoliasearch_popular_queries_cache_tag'; + protected $popularQueriesCacheId = 'algoliasearch_popular_queries_cache_tag'; /** * SuggestionHelper constructor. @@ -50,11 +59,18 @@ public function __construct( $this->serializer = $serializer; } + /** + * @return string + */ public function getIndexNameSuffix() { return '_suggestions'; } + /** + * @param $storeId + * @return array|mixed|null + */ public function getIndexSettings($storeId) { $indexSettings = [ @@ -69,11 +85,13 @@ public function getIndexSettings($storeId) 'algolia_suggestions_index_before_set_settings', ['store_id' => $storeId, 'index_settings' => $transport] ); - $indexSettings = $transport->getData(); - - return $indexSettings; + return $transport->getData(); } + /** + * @param Query $suggestion + * @return array|mixed|null + */ public function getObject(Query $suggestion) { $suggestionObject = [ @@ -89,23 +107,27 @@ public function getObject(Query $suggestion) 'algolia_after_create_suggestion_object', ['suggestion' => $transport, 'suggestionObject' => $suggestion] ); - $suggestionObject = $transport->getData(); - - return $suggestionObject; + return $transport->getData(); } - public function getPopularQueries($storeId) + /** + * @param $storeId + * @return array|bool|float|int|string|null + */ + public function getPopularQueries($storeId = null) { + if (!$this->configHelper->isInstantEnabled($storeId) || !$this->configHelper->showSuggestionsOnNoResultsPage($storeId)) { + return []; + } $queries = $this->cache->load($this->popularQueriesCacheId); if ($queries !== false) { return $this->serializer->unserialize($queries); } - /** @var \Magento\Search\Model\ResourceModel\Query\Collection $collection */ $collection = $this->queryCollectionFactory->create(); $collection->getSelect()->where( - 'num_results >= ' . $this->configHelper->getMinNumberOfResults() . ' - AND popularity >= ' . $this->configHelper->getMinPopularity() . ' + 'num_results >= ' . $this->configHelper->getMinNumberOfResults() . ' + AND popularity >= ' . $this->configHelper->getMinPopularity() . ' AND query_text != "__empty__" AND CHAR_LENGTH(query_text) >= 3' ); @@ -126,16 +148,19 @@ public function getPopularQueries($storeId) return $queries; } + /** + * @param $storeId + * @return \Magento\Search\Model\ResourceModel\Query\Collection + */ public function getSuggestionCollectionQuery($storeId) { - /** @var \Magento\Search\Model\ResourceModel\Query\Collection $collection */ $collection = $this->queryCollectionFactory->create() ->addStoreFilter($storeId) ->setStoreId($storeId); $collection->getSelect()->where( - 'num_results >= ' . $this->configHelper->getMinNumberOfResults($storeId) . ' - AND popularity >= ' . $this->configHelper->getMinPopularity($storeId) . ' + 'num_results >= ' . $this->configHelper->getMinNumberOfResults($storeId) . ' + AND popularity >= ' . $this->configHelper->getMinPopularity($storeId) . ' AND query_text != "__empty__"' ); From e5df5f3538bf956a34ed726f41a2aedbfdd31bfb Mon Sep 17 00:00:00 2001 From: Mohit Choudhary Date: Tue, 29 Nov 2022 14:39:33 +0530 Subject: [PATCH 51/55] readme update for 3.9.1 --- README.md | 2 +- composer.json | 2 +- etc/module.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cf0a8fcf7..afce37437 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Algolia Search for Magento 2 ================== -![Latest version](https://img.shields.io/badge/latest-3.9.0-green) +![Latest version](https://img.shields.io/badge/latest-3.9.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) diff --git a/composer.json b/composer.json index bed1b8c62..fafe165a8 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Algolia Search integration for Magento 2", "type": "magento2-module", "license": ["MIT"], - "version": "3.9.0", + "version": "3.9.1", "require": { "magento/framework": "~102.0|~103.0", "algolia/algoliasearch-client-php": "3.2", diff --git a/etc/module.xml b/etc/module.xml index 14805cd98..f58693da2 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - + From bce500f0d607600b46d9c3903c6de44e8e14036a Mon Sep 17 00:00:00 2001 From: Mohit Choudhary Date: Tue, 29 Nov 2022 15:37:37 +0530 Subject: [PATCH 52/55] Updated changelog --- CHANGELOG.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d97f37bc1..ec3cdbc35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ # CHANGE LOG +## 3.9.1 + +### UPDATES +- Refactored the Autocomplete to provide an extensible model for function-based templates utilizing tagged template literals. The approach supports the use of RequireJS mixins for overriding template functionality and additional bug fixes in the Autocomplete. + - Autocomplete category links not preselecting facets on the target URL + - Standardizes template function naming conventions for all autocomplete template types + - Provides better scoping of variables and reducing dependencies on globals and the window object + - Fixed bug related to conjunctive facets and adaptive images + +- Update the synonym area text in the Magento configuration to point customers to use the Algolia dashboard +- Refactored the casting Attributes + + + +### FIXES +- When autocomplete was disabled __empty__ was showing in the URL +- Instant search fixes when the price was set to retrievable = 'no' +- Price attribute fixes in autocomplete, when the price attribute is set to Non-Retrievable +- Add to cart triggering duplicate view event for the Algolia recommend products +- Issues while saving and loading data by the wrong cache key for the popular queries +- Issues with max_retries in clear old jobs function in the queue +- Place Order duplicate Conversion issue for Grouped Product + + + ## 3.9.0 ### New Features From 22ade2bb36500be82bc0c7cba54b98e8840463af Mon Sep 17 00:00:00 2001 From: Mohit Choudhary Date: Tue, 29 Nov 2022 17:28:43 +0530 Subject: [PATCH 53/55] Fixed code conflict --- Block/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Block/Configuration.php b/Block/Configuration.php index 80857b6dc..5cb1bebf9 100755 --- a/Block/Configuration.php +++ b/Block/Configuration.php @@ -228,7 +228,7 @@ public function getConfiguration() 'showCatsNotIncludedInNavigation' => $config->showCatsNotIncludedInNavigation(), 'showSuggestionsOnNoResultsPage' => $config->showSuggestionsOnNoResultsPage(), 'baseUrl' => $baseUrl, - 'popularQueries' => $suggestionHelper->getPopularQueries(), + 'popularQueries' => $suggestionHelper->getPopularQueries($this->getStoreId()), 'useAdaptiveImage' => $config->useAdaptiveImage(), 'urls' => [ 'logo' => $this->getViewFileUrl('Algolia_AlgoliaSearch::images/algolia-logo-blue.svg'), From 0632f5f84718700bd6117a3670d75367cc5ef52a Mon Sep 17 00:00:00 2001 From: Mohit Choudhary Date: Tue, 29 Nov 2022 20:33:12 +0530 Subject: [PATCH 54/55] Updated changelog --- CHANGELOG.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec3cdbc35..07960a38c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,25 +3,25 @@ ## 3.9.1 ### UPDATES -- Refactored the Autocomplete to provide an extensible model for function-based templates utilizing tagged template literals. The approach supports the use of RequireJS mixins for overriding template functionality and additional bug fixes in the Autocomplete. - - Autocomplete category links not preselecting facets on the target URL - - Standardizes template function naming conventions for all autocomplete template types - - Provides better scoping of variables and reducing dependencies on globals and the window object - - Fixed bug related to conjunctive facets and adaptive images - -- Update the synonym area text in the Magento configuration to point customers to use the Algolia dashboard +- Refactored the Autocomplete to provide an extensible model for function-based templates by utilizing tagged template literals. The approach supports the use of RequireJS mixins for overriding the template functionality. +- Update the synonym area text in the Magento configuration to point customers to use the Algolia dashboard as Synonym management from Magento Dashboard will be deprecated in a future release - Refactored the casting Attributes +- Managing Max record size via the admin ### FIXES +- Autocomplete category links not preselecting facets on the target URL +- Fixed bug related to conjunctive facets and adaptive images in autocomplete - When autocomplete was disabled __empty__ was showing in the URL - Instant search fixes when the price was set to retrievable = 'no' -- Price attribute fixes in autocomplete, when the price attribute is set to Non-Retrievable +- Price attribute fixes in autocomplete when the price attribute is set to Non-Retrievable - Add to cart triggering duplicate view event for the Algolia recommend products - Issues while saving and loading data by the wrong cache key for the popular queries - Issues with max_retries in clear old jobs function in the queue - Place Order duplicate Conversion issue for Grouped Product +- Fixes the issues with store-specific category index + From feeca61d15e40cf93fb2dfd7658c97a7b58d27b3 Mon Sep 17 00:00:00 2001 From: Mohit Choudhary Date: Tue, 29 Nov 2022 20:48:46 +0530 Subject: [PATCH 55/55] Updated changelog --- CHANGELOG.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07960a38c..9fdf3dbb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,25 +3,24 @@ ## 3.9.1 ### UPDATES -- Refactored the Autocomplete to provide an extensible model for function-based templates by utilizing tagged template literals. The approach supports the use of RequireJS mixins for overriding the template functionality. -- Update the synonym area text in the Magento configuration to point customers to use the Algolia dashboard as Synonym management from Magento Dashboard will be deprecated in a future release +- Refactored the Autocomplete to provide an extensible model for function-based templates by utilizing tagged template literals. The approach supports the use of RequireJS mixins for overriding the template functionality. +- Update the synonym area notice in the Magento admin to point customers to use the Algolia dashboard for Synonym management as Magento Dashboard will be deprecated in a future release - Refactored the casting Attributes - Managing Max record size via the admin - ### FIXES - Autocomplete category links not preselecting facets on the target URL - Fixed bug related to conjunctive facets and adaptive images in autocomplete -- When autocomplete was disabled __empty__ was showing in the URL +- Fixed issue with showing __empty__ in the url if autocomplete was disabled +- Fixed autocomplete suggestions - Instant search fixes when the price was set to retrievable = 'no' - Price attribute fixes in autocomplete when the price attribute is set to Non-Retrievable - Add to cart triggering duplicate view event for the Algolia recommend products - Issues while saving and loading data by the wrong cache key for the popular queries - Issues with max_retries in clear old jobs function in the queue - Place Order duplicate Conversion issue for Grouped Product -- Fixes the issues with store-specific category index - +- Fixes issues with store-specific category index