Skip to content

Commit 0611e75

Browse files
authored
Merge pull request #9213 from magento-gl/AC-12482
[Arrows] Platform Health Delivery
2 parents 8459b17 + 7aa3a0e commit 0611e75

File tree

87 files changed

+337
-252
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+337
-252
lines changed

app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml

Lines changed: 61 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
</div>
1919
<div class="tree-actions">
2020
<?php if ($root):?>
21-
<a id="colapseAll" href="#"><?= $block->escapeHtml(__('Collapse All')) ?></a>
21+
<a id="colapseAll" href="#"><?= $escaper->escapeHtml(__('Collapse All')) ?></a>
2222
<span class="separator">|</span>
23-
<a id="expandAll" href="#"><?= $block->escapeHtml(__('Expand All')) ?></a>
23+
<a id="expandAll" href="#"><?= $escaper->escapeHtml(__('Expand All')) ?></a>
2424
<?php endif; ?>
2525
</div>
2626
<?php if ($root):?>
@@ -39,11 +39,11 @@
3939
</div>
4040
</div>
4141

42-
<div data-id="information-dialog-tree" class="messages">
43-
<div class="message message-notice">
44-
<div><?= $block->escapeHtml(__('This operation can take a long time')) ?></div>
42+
<div data-id="information-dialog-tree" class="messages">
43+
<div class="message message-notice">
44+
<div><?= $escaper->escapeHtml(__('This operation can take a long time')) ?></div>
45+
</div>
4546
</div>
46-
</div>
4747

4848
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag(
4949
'display: none;',
@@ -73,7 +73,7 @@
7373
treeInstance,
7474
script;
7575
$scriptString .= 'currentNodeId = ' . (int)$block->getCategoryId() . ',
76-
76+
defaultTree = '. $block->getTreeJson() .',
7777
defaultParams = {
7878
text: ' . /* @noEscape */ json_encode(htmlentities($root->getName())) . ',
7979
allowDrop: ' . ($root->getIsVisible() ? 'true' : 'false') . ',
@@ -93,6 +93,32 @@ script;
9393
*/
9494
treeDiv.jstree({
9595
core: {
96+
'data' : function (obj, callback) {
97+
if(obj.id != '#' && obj.children.length === 0){
98+
let data = {
99+
id: obj.id,
100+
store: defaultParams.store_id,
101+
form_key: FORM_KEY
102+
};
103+
104+
$.ajax({
105+
url: '{$block->escapeJs($block->getLoadTreeUrl())}',
106+
type: "POST",
107+
data: data,
108+
dataType: 'json',
109+
success: function (response) {
110+
TreeConfig.updateChildrenKey(response);
111+
callback.call(this, response);
112+
},
113+
error: function (jqXHR, status, error) {
114+
console.log(status + ': ' + error);
115+
}
116+
});
117+
}else{
118+
TreeConfig.updateChildrenKey(defaultTree);
119+
callback.call(this, defaultTree);
120+
}
121+
},
96122
check_callback: function (operation, node) {
97123
//Draggable false for root categories
98124
return !(operation === 'move_node' &&
@@ -102,57 +128,10 @@ script;
102128
plugins: ['dnd'],
103129
}).bind('move_node.jstree', function (e, data) {
104130
TreeConfig.categoryMove(data);
131+
}).bind('ready.jstree', function(e, data) {
132+
TreeConfig.selectNode(data);
105133
});
106-
107134
treeInstance = treeDiv.jstree(true);
108-
let root = treeInstance.get_node('#');
109-
this.buildCategoryTree(treeDiv, root, '{$block->getTreeJson()}', true);
110-
111-
let catId = treeInstance.get_node(defaultParams.category_id);
112-
if (catId) {
113-
currentNodeId = defaultParams.category_id;
114-
} else if (defaultParams.parent > 0 && defaultParams.category_id === 0) {
115-
currentNodeId = defaultParams.parent;
116-
}
117-
118-
// select and open child node
119-
if (defaultParams.expanded) {
120-
treeInstance.open_all();
121-
} else {
122-
let selectedNode = treeInstance.get_node(currentNodeId);
123-
treeInstance.select_node(selectedNode, true);
124-
125-
setTimeout(function () {
126-
treeInstance.open_node(selectedNode);
127-
}, 15);
128-
}
129-
},
130-
131-
buildCategoryTree: function(treeDiv, parent, config, firstLoad){
132-
if (!config) return;
133-
134-
if(firstLoad){
135-
config = $.parseJSON(config);
136-
}
137-
138-
for (let i = 0; i < config.length; i++) {
139-
let nodeConfig = config[i],
140-
newNode = {
141-
text: nodeConfig.text,
142-
id: nodeConfig.id,
143-
allowDrag: nodeConfig.allowDrag,
144-
allowDrop: nodeConfig.allowDrop,
145-
cls: nodeConfig.cls,
146-
store: nodeConfig.store,
147-
li_attr: { class: nodeConfig.cls}
148-
};
149-
150-
const parentTree = treeInstance.create_node(parent, newNode, 'last');
151-
152-
if (nodeConfig.children) {
153-
this.buildCategoryTree(treeDiv, parentTree, nodeConfig.children, false);
154-
}
155-
}
156135
},
157136
158137
categoryMove : function (obj){
@@ -237,10 +216,33 @@ script;
237216
treeDiv.on('changed.jstree', function (e, data) {
238217
TreeConfig.categoryClick(data);
239218
});
219+
},
240220
241-
treeDiv.on("open_node.jstree", function (e, data) {
242-
TreeConfig.handleOpenNode(data);
243-
});
221+
updateChildrenKey : function(treeJson) {
222+
treeJson.forEach(node => {
223+
if (Array.isArray(node.children) && node.children.length === 0) {
224+
node.children = true;
225+
} else if (Array.isArray(node.children)) {
226+
TreeConfig.updateChildrenKey(node.children);
227+
}
228+
});
229+
},
230+
231+
selectNode : function(data){
232+
if (defaultParams.expanded) {
233+
treeInstance.open_all();
234+
} else {
235+
let catId = treeInstance.get_node(defaultParams.category_id);
236+
if (catId) {
237+
currentNodeId = defaultParams.category_id;
238+
} else if (defaultParams.parent > 0 && defaultParams.category_id === 0) {
239+
currentNodeId = defaultParams.parent;
240+
}
241+
242+
let selectedNode = treeInstance.get_node(currentNodeId);
243+
treeInstance.select_node(selectedNode, true);
244+
treeInstance.open_node(selectedNode);
245+
}
244246
},
245247
246248
categoryClick : function(data){
@@ -257,63 +259,6 @@ script;
257259
}
258260
},
259261
260-
handleOpenNode : function(data){
261-
let parentNode = data.node;
262-
if (parentNode && parentNode.children.length > 0) {
263-
264-
parentNode.children.forEach(function(childId) {
265-
266-
let childNode = data.instance.get_node(childId, false);
267-
268-
// Check if the child node has no children (is not yet loaded)
269-
if (childNode.children && childNode.children.length === 0
270-
&& childNode.original && !childNode.original.lastNode) {
271-
272-
$.ajax({
273-
url: '{$block->escapeJs($block->escapeUrl($block->getLoadTreeUrl()))}',
274-
type: "POST",
275-
data: {
276-
id: childNode.original.id,
277-
store: childNode.original.store,
278-
form_key: FORM_KEY
279-
},
280-
dataType: 'json',
281-
success: function (response) {
282-
TreeConfig.handleSuccessResponse(response, childNode, data);
283-
},
284-
error: function (jqXHR, status, error) {
285-
console.log(status + ': ' + error);
286-
}
287-
});
288-
}
289-
});
290-
}
291-
},
292-
293-
handleSuccessResponse : function(response, childNode, data){
294-
if (response.length > 0) {
295-
response.forEach(newNode => {
296-
TreeConfig.addLastNodeFlag(newNode);
297-
298-
// Create the new node and execute node callback
299-
data.instance.create_node(childNode, newNode, 'last');
300-
});
301-
302-
// open all node if, expand all link clicked
303-
if(expandAll === true){
304-
data.instance.open_all();
305-
}
306-
}
307-
},
308-
309-
addLastNodeFlag : function(treeData) {
310-
if (treeData.children) {
311-
treeData.children.forEach(child => TreeConfig.addLastNodeFlag(child));
312-
} else {
313-
treeData.lastNode = true;
314-
}
315-
},
316-
317262
expandAll : function(){
318263
expandAll = true;
319264
treeInstance.open_all();
@@ -343,13 +288,6 @@ script;
343288
TreeConfig.categoryClick(data);
344289
});
345290
346-
/**
347-
* jstree handle open node
348-
*/
349-
treeDiv.on('open_node.jstree', function (e, data) {
350-
TreeConfig.handleOpenNode(data);
351-
});
352-
353291
/**
354292
* create default tree
355293
*/

app/code/Magento/CatalogSearch/i18n/en_US.csv

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,6 @@ name,name
3939
"Rebuild Catalog product fulltext search index","Rebuild Catalog product fulltext search index"
4040
"Please enter a valid price range.","Please enter a valid price range."
4141
"This value must be compatible with the corresponding setting in the configured search engine. Be aware: a low query length limit may cause the performance impact.","This value must be compatible with the corresponding setting in the configured search engine. Be aware: a low query length limit may cause the performance impact."
42-
"This value must be compatible with the corresponding setting in the configured search engine.","This value must be compatible with the corresponding setting in the configured search engine."
42+
"This value must be compatible with the corresponding setting in the configured search engine.","This value must be compatible with the corresponding setting in the configured search engine."
43+
"If not specified, Default Search Engine will be used.","If not specified, Default Search Engine will be used."
44+
"This search engine option is no longer supported by Adobe. It is recommended to use OpenSearch as a search engine instead.","This search engine option is no longer supported by Adobe. It is recommended to use OpenSearch as a search engine instead."
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright 2024 Adobe
5+
* All Rights Reserved.
6+
*/
7+
-->
8+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
9+
<body>
10+
<referenceContainer name="js">
11+
<block class="Magento\Backend\Block\Template" name="search_engine_comment_js" template="Magento_CatalogSearch::search_engine_comment.phtml"/>
12+
</referenceContainer>
13+
</body>
14+
</page>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*/
6+
?>
7+
<script type="text/x-magento-init">
8+
{
9+
"*": {
10+
"Magento_CatalogSearch/js/search-engine-comment": {}
11+
}
12+
}
13+
</script>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Copyright 2024 Adobe
3+
* All Rights Reserved.
4+
*/
5+
require([
6+
'jquery',
7+
'domReady!',
8+
'mage/translate'
9+
], function ($) {
10+
'use strict';
11+
12+
$(function () {
13+
const engineField = $('#catalog_search_engine'),
14+
commentContainer = $('#row_catalog_search_engine p'),
15+
defaultText = $.mage.__('If not specified, Default Search Engine will be used.'),
16+
unsupportedText = $.mage.__('This search engine option is no longer supported by Adobe. ' +
17+
'It is recommended to use OpenSearch as a search engine instead.'),
18+
updateCommentText = () => {
19+
const engineValue = engineField.val(),
20+
newCommentText = ['elasticsearch7', 'elasticsearch8'].includes(engineValue) ?
21+
unsupportedText : defaultText;
22+
23+
if (commentContainer.text() !== newCommentText) {
24+
commentContainer.text(newCommentText);
25+
}
26+
};
27+
28+
engineField.change(updateCommentText);
29+
updateCommentText();
30+
});
31+
});

app/code/Magento/Elasticsearch/ElasticAdapter/Model/Adapter/BatchDataMapper/CategoryFieldsProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
/**
1616
* Provide data mapping for categories fields
17+
* @deprecated Elasticsearch is no longer supported by Adobe
18+
* @see this class will be responsible for ES only
1719
*/
1820
class CategoryFieldsProvider implements AdditionalFieldsProviderInterface
1921
{

app/code/Magento/Elasticsearch/ElasticAdapter/Model/Adapter/BatchDataMapper/CategoryFieldsProviderProxy.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
/**
1212
* Proxy for data mapping of categories fields
13+
* @deprecated Elasticsearch is no longer supported by Adobe
14+
* @see this class will be responsible for ES only
1315
*/
1416
class CategoryFieldsProviderProxy implements AdditionalFieldsProviderInterface
1517
{

app/code/Magento/Elasticsearch/ElasticAdapter/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/Converter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
/**
1313
* Field type converter from internal index type to elastic service.
14+
* @deprecated Elasticsearch is no longer supported by Adobe
15+
* @see this class will be responsible for ES only
1416
*/
1517
class Converter implements ConverterInterface
1618
{

app/code/Magento/Elasticsearch/ElasticAdapter/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/IndexResolver.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* Field index resolver that provides index type for the attribute in mapping.
2020
* For example, we need to set ‘no’/false in the case when attribute must be present in index data,
2121
* but stay as not indexable.
22+
* @deprecated Elasticsearch is no longer supported by Adobe
23+
* @see this class will be responsible for ES only
2224
*/
2325
class IndexResolver implements ResolverInterface
2426
{

app/code/Magento/Elasticsearch/ElasticAdapter/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Converter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
/**
1313
* Field type converter from internal data types to elastic service.
14+
* @deprecated Elasticsearch is no longer supported by Adobe
15+
* @see this class will be responsible for ES only
1416
*/
1517
class Converter implements ConverterInterface
1618
{

app/code/Magento/Elasticsearch/ElasticAdapter/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/CompositeResolver.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
/**
1414
* Composite resolver for resolving field type.
15+
* @deprecated Elasticsearch is no longer supported by Adobe
16+
* @see this class will be responsible for ES only
1517
*/
1618
class CompositeResolver implements ResolverInterface
1719
{

app/code/Magento/Elasticsearch/ElasticAdapter/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
/**
1515
* Integer type resolver.
16+
* @deprecated Elasticsearch is no longer supported by Adobe
17+
* @see this class will be responsible for ES only
1618
*/
1719
class IntegerType implements ResolverInterface
1820
{

app/code/Magento/Elasticsearch/ElasticAdapter/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/KeywordType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
/**
1515
* Keyword type resolver.
16+
* @deprecated Elasticsearch is no longer supported by Adobe
17+
* @see this class will be responsible for ES only
1618
*/
1719
class KeywordType implements ResolverInterface
1820
{

app/code/Magento/Elasticsearch/ElasticAdapter/Model/Adapter/FieldMapper/ProductFieldMapper.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
/**
1616
* Class ProductFieldMapper provides field name by attribute code and retrieve all attribute types
17+
* @deprecated Elasticsearch is no longer supported by Adobe
18+
* @see this class will be responsible for ES only
1719
*/
1820
class ProductFieldMapper implements FieldMapperInterface
1921
{

0 commit comments

Comments
 (0)