@things-factory/integration-sellercraft 4.1.40 → 4.2.2

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.
Files changed (25) hide show
  1. package/dist-server/constants/order-status-mapping.js +7 -3
  2. package/dist-server/constants/order-status-mapping.js.map +1 -1
  3. package/dist-server/constants/platform.js +2 -1
  4. package/dist-server/constants/platform.js.map +1 -1
  5. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.js +17 -21
  6. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.js.map +1 -1
  7. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js +2 -2
  8. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js.map +1 -1
  9. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js +13 -5
  10. package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js.map +1 -1
  11. package/dist-server/routers/sellercraft-router.js +26 -11
  12. package/dist-server/routers/sellercraft-router.js.map +1 -1
  13. package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js +181 -19
  14. package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js.map +1 -1
  15. package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js +23 -9
  16. package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js.map +1 -1
  17. package/package.json +3 -3
  18. package/server/constants/order-status-mapping.ts +7 -3
  19. package/server/constants/platform.ts +2 -1
  20. package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.ts +17 -21
  21. package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.ts +3 -3
  22. package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.ts +19 -5
  23. package/server/routers/sellercraft-router.ts +27 -12
  24. package/server/service/marketplace-channel/marketplace-channel-order-mutation.ts +186 -19
  25. package/server/service/marketplace-channel/marketplace-channel-product-mutation.ts +24 -9
@@ -37,7 +37,8 @@ export class MarketplaceChannelProductMutation {
37
37
  accessKey: shops[j].credential.consumer_key,
38
38
  accessSecret: shops[j].credential.consumer_secret,
39
39
  storeURL: shops[j].credential.store_url,
40
- platform: channels[i].name
40
+ platform: channels[i].name,
41
+ accessToken: shops[j].credential.access_token // Magento+
41
42
  }
42
43
 
43
44
  let countryCode = shops[j].country_code
@@ -47,12 +48,22 @@ export class MarketplaceChannelProductMutation {
47
48
 
48
49
  var sellercraftStore = { ...store, platform: 'sellercraftChannelIntegration' }
49
50
 
50
- const productResult = await StoreAPI.getStoreProducts(store, {})
51
+ const productResult = []
52
+ let totalPages: number = 1
53
+ var limit: number = 50
54
+
55
+ for (let page = 0; page < totalPages; page++) {
56
+ const { results, total } = await StoreAPI.getStoreProducts(store, {
57
+ pagination: { page, limit }
58
+ })
59
+ totalPages = Math.ceil(total / limit)
60
+ productResult.push(...results)
61
+ }
51
62
 
52
63
  const categoryResult = await StoreAPI.getStoreProductCategories(store, {})
53
64
 
54
- let mappedProducts = productResult.results.map(item => {
55
- let { categoryId, itemId: productId, name, brand, isVerified, images, attributes, variations } = item
65
+ let mappedProducts = productResult.map(item => {
66
+ let { categoryId, itemId: productId, parentId, name, brand, isVerified, images, attributes, variations } = item
56
67
 
57
68
  variations = variations.map(variation => {
58
69
  let {
@@ -103,7 +114,7 @@ export class MarketplaceChannelProductMutation {
103
114
  }
104
115
  })
105
116
 
106
- images = images.map(image => {
117
+ images = images?.map(image => {
107
118
  return {
108
119
  url: image
109
120
  }
@@ -115,7 +126,7 @@ export class MarketplaceChannelProductMutation {
115
126
  channelCode: channels[i].channelCode,
116
127
  channelCountry: shops[j].country_code,
117
128
  categoryId,
118
- productId,
129
+ productId: parentId || productId,
119
130
  name,
120
131
  brand,
121
132
  isVerified,
@@ -135,12 +146,16 @@ export class MarketplaceChannelProductMutation {
135
146
  isLeaf: parent == 0 ? false : true,
136
147
  isActive: isActive || true,
137
148
  channelCode,
138
- countryCode
149
+ countryCode,
150
+ childrenCategories: []
139
151
  }
140
152
  })
141
153
 
142
- mappedCategories.map(category => {
143
- category.childrenCategories = mappedCategories.filter(e => e.parent == category.categoryId)
154
+ mappedCategories = mappedCategories.map(category => {
155
+ if (mappedCategories.filter(e => e.parent == category.categoryId).length > 0) {
156
+ category.childrenCategories = mappedCategories.filter(e => e.parent == category.categoryId)
157
+ }
158
+ return category
144
159
  })
145
160
 
146
161
  await SellercraftChannelIntegrationAPI.ingestChannelCategories(sellercraftStore, {