Skip to content

Commit a1e6c0f

Browse files
authored
Merge pull request #351 from magento-obsessive-owls/PB-315
[Owls] PB-315 [PB-1.1.1 Backport] Products lose their conditions after upgrade
2 parents 994325b + f98a1cf commit a1e6c0f

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/products/mass-converter/widget-directive.js

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/products/mass-converter/widget-directive.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,13 @@ export default class WidgetDirective extends BaseWidgetDirective {
4646
id_path: "",
4747
show_pager: 0,
4848
products_count: data.products_count,
49-
sort_order: data.sort_order,
5049
type_name: "Catalog Products List",
5150
conditions_encoded: this.encodeWysiwygCharacters(data.conditions_encoded || ""),
52-
};
51+
} as { [key: string]: any; };
52+
53+
if (data.sort_order) {
54+
attributes.sort_order = data.sort_order;
55+
}
5356

5457
if (attributes.conditions_encoded.length === 0) {
5558
return data;

dev/tests/js/jasmine/tests/app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/products/mass-converter/widget-directive.test.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ define([
6969
it('Should transform regular properties', function () {
7070
var data = {
7171
products_count: 123,
72-
conditions_encoded: '[]'
72+
conditions_encoded: '[]',
73+
sort_order: 'date_newest_top'
7374
},
7475
config = {
7576
html_variable: 'myhtml'
@@ -85,6 +86,7 @@ define([
8586
expect(result.myhtml).toContain(' id_path=""');
8687
expect(result.myhtml).toContain(' show_pager="0"');
8788
expect(result.myhtml).toContain(' type_name="Catalog Products List"');
89+
expect(result.myhtml).toContain(' sort_order="date_newest_top');
8890
});
8991
it('Should encode conditions_encoded', function () {
9092
var data = {
@@ -105,6 +107,18 @@ define([
105107
expect(result.myhtml).toContain(' show_pager="0"');
106108
expect(result.myhtml).toContain(' type_name="Catalog Products List"');
107109
});
110+
it('Should not add empty sort_order attribute', function () {
111+
var data = {
112+
products_count: 123,
113+
conditions_encoded: '[]'
114+
},
115+
config = {
116+
html_variable: 'myhtml'
117+
},
118+
result = model.toDom(data, config);
119+
120+
expect(result.myhtml).not.toContain('sort_order');
121+
});
108122
});
109123
describe('fromDom', function () {
110124
it('Should parse regular properties without conditions_encoded', function () {

0 commit comments

Comments
 (0)