oneentry 1.0.54 → 1.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/blocks/blocksApi.js +40 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -560,7 +560,7 @@ example: null <br>
|
|
|
560
560
|
</details>
|
|
561
561
|
---
|
|
562
562
|
|
|
563
|
-
|
|
563
|
+
### Blocks.getSimilarProducts(marker, langCode, offset, limit)
|
|
564
564
|
|
|
565
565
|
|
|
566
566
|
```js
|
|
@@ -607,7 +607,7 @@ Example return:
|
|
|
607
607
|
|
|
608
608
|
|
|
609
609
|
|
|
610
|
-
|
|
610
|
+
### Blocks.getSimilarProducts(marker, langCode, offset, limit)
|
|
611
611
|
|
|
612
612
|
```js
|
|
613
613
|
const value = await Blocks.getProductsByBlockMarker('my-marker', 'en_US')
|
package/dist/blocks/blocksApi.js
CHANGED
|
@@ -23,21 +23,34 @@ class BlocksApi extends oneEntry_1.default {
|
|
|
23
23
|
const normalizeResponse = this._normalizeData(response);
|
|
24
24
|
await Promise.all(normalizeResponse.map(async (block) => {
|
|
25
25
|
const customSettings = block.customSettings;
|
|
26
|
-
if (customSettings.hasOwnProperty('productConfig')) {
|
|
26
|
+
if (customSettings && customSettings.hasOwnProperty('productConfig')) {
|
|
27
27
|
block.countElementsPerRow = customSettings.productConfig.countElementsPerRow ? (+customSettings.productConfig.countElementsPerRow) : 0;
|
|
28
28
|
}
|
|
29
|
+
else {
|
|
30
|
+
block.countElementsPerRow = 0;
|
|
31
|
+
}
|
|
29
32
|
delete block.customSettings;
|
|
30
33
|
delete block.attributeSetId;
|
|
31
34
|
delete block.productPageUrls;
|
|
32
35
|
if (block.type === 'forSimilarProductBlock') {
|
|
33
|
-
|
|
34
|
-
block.
|
|
35
|
-
|
|
36
|
+
try {
|
|
37
|
+
await this.getSimilarProducts(block.identifier, langCode, offset, limit).then((result) => {
|
|
38
|
+
block.similarProducts = result;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
block.similarProducts = [];
|
|
43
|
+
}
|
|
36
44
|
}
|
|
37
45
|
else if (block.type === 'forProductBlock') {
|
|
38
|
-
|
|
39
|
-
block.
|
|
40
|
-
|
|
46
|
+
try {
|
|
47
|
+
await this.getProductsByBlockMarker(block.identifier, langCode, offset, limit).then((result) => {
|
|
48
|
+
block.products = result;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
block.products = [];
|
|
53
|
+
}
|
|
41
54
|
}
|
|
42
55
|
}));
|
|
43
56
|
return normalizeResponse;
|
|
@@ -54,21 +67,34 @@ class BlocksApi extends oneEntry_1.default {
|
|
|
54
67
|
const response = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
55
68
|
const normalizeResponse = this._normalizeData(response);
|
|
56
69
|
const customSettings = normalizeResponse.customSettings;
|
|
57
|
-
if (customSettings.hasOwnProperty('productConfig')) {
|
|
70
|
+
if (customSettings && customSettings.hasOwnProperty('productConfig')) {
|
|
58
71
|
normalizeResponse.countElementsPerRow = customSettings.productConfig.countElementsPerRow ? (+customSettings.productConfig.countElementsPerRow) : 0;
|
|
59
72
|
}
|
|
73
|
+
else {
|
|
74
|
+
normalizeResponse.countElementsPerRow = 0;
|
|
75
|
+
}
|
|
60
76
|
delete normalizeResponse.customSettings;
|
|
61
77
|
delete normalizeResponse.attributeSetId;
|
|
62
78
|
delete normalizeResponse.productPageUrls;
|
|
63
79
|
if (normalizeResponse.type === 'forSimilarProductBlock') {
|
|
64
|
-
|
|
65
|
-
normalizeResponse.
|
|
66
|
-
|
|
80
|
+
try {
|
|
81
|
+
await this.getSimilarProducts(normalizeResponse.identifier, langCode).then((result) => {
|
|
82
|
+
normalizeResponse.similarProducts = result;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
normalizeResponse.similarProducts = [];
|
|
87
|
+
}
|
|
67
88
|
}
|
|
68
89
|
else if (normalizeResponse.type === 'forProductBlock') {
|
|
69
|
-
|
|
70
|
-
normalizeResponse.
|
|
71
|
-
|
|
90
|
+
try {
|
|
91
|
+
await this.getProductsByBlockMarker(normalizeResponse.identifier, langCode).then((result) => {
|
|
92
|
+
normalizeResponse.products = result;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
normalizeResponse.products = [];
|
|
97
|
+
}
|
|
72
98
|
}
|
|
73
99
|
return normalizeResponse;
|
|
74
100
|
}
|