@reactionary/provider-commercetools 0.0.76 → 0.0.77
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/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactionary/provider-commercetools",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.77",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "src/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@reactionary/core": "0.0.
|
|
7
|
+
"@reactionary/core": "0.0.77",
|
|
8
8
|
"debug": "^4.4.3",
|
|
9
9
|
"zod": "4.1.9",
|
|
10
10
|
"@commercetools/ts-client": "^4.2.1",
|
|
@@ -22,19 +22,29 @@ class CommercetoolsInventoryProvider extends InventoryProvider {
|
|
|
22
22
|
}
|
|
23
23
|
async getBySKU(payload) {
|
|
24
24
|
const client = await this.getClient();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
try {
|
|
26
|
+
const channel = await client.channels().withKey({ key: payload.fulfilmentCenter.key }).get().execute();
|
|
27
|
+
const channelId = channel.body.id;
|
|
28
|
+
const remote = await client.inventory().get({
|
|
29
|
+
queryArgs: {
|
|
30
|
+
where: "sku=:sku AND supplyChannel(id=:channel)",
|
|
31
|
+
"var.sku": payload.variant.sku,
|
|
32
|
+
"var.channel": channelId,
|
|
33
|
+
expand: "supplyChannel"
|
|
34
|
+
}
|
|
35
|
+
}).execute();
|
|
36
|
+
const result = remote.body.results[0];
|
|
37
|
+
const model = this.parseSingle(result);
|
|
38
|
+
return model;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error("Error fetching inventory by SKU and Fulfillment Center:", error, payload);
|
|
41
|
+
return this.createEmptyInventory(
|
|
42
|
+
{
|
|
43
|
+
variant: { sku: payload.variant.sku },
|
|
44
|
+
fulfillmentCenter: { key: payload.fulfilmentCenter.key }
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
38
48
|
}
|
|
39
49
|
parseSingle(body) {
|
|
40
50
|
const model = this.newModel();
|
|
@@ -77,7 +77,9 @@ class CommercetoolsProductProvider extends ProductProvider {
|
|
|
77
77
|
if (data.description) {
|
|
78
78
|
base.description = data.description[this.context.languageContext.locale];
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
const variantLevelAttributes = data.masterVariant.attributes?.map((x) => this.parseAttribute(x)) || [];
|
|
81
|
+
const productLevelAttributes = data.attributes.map((x) => this.parseAttribute(x)) || [];
|
|
82
|
+
base.sharedAttributes = [...productLevelAttributes, ...variantLevelAttributes];
|
|
81
83
|
base.mainVariant = this.parseVariant(data.masterVariant, data);
|
|
82
84
|
base.meta = {
|
|
83
85
|
cache: { hit: false, key: this.generateCacheKeySingle(base.identifier) },
|