Skip to content

Commit 2b760cf

Browse files
committed
fix: properly passing app data on product parse for imports
preventing errors with undefined `appData` object
1 parent 3628b6b commit 2b760cf

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

functions/lib/integration/import-product.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ module.exports = ({ appSdk, storeId, auth }, tinyToken, queueEntry, appData, can
176176
}
177177
return null
178178
} else if (!product && tinyProduct && tipo === 'produto') {
179-
return parseProduct(tinyProduct, storeId, auth, true, tipo).then(product => {
179+
return parseProduct(tinyProduct, storeId, auth, true, tipo, appData).then(product => {
180180
return appSdk.apiRequest(storeId, '/products.json', 'POST', product, auth).then(async (response) => {
181181
const { response: { data: { _id: newProductId } } } = response
182182

functions/lib/integration/parsers/product-to-ecomplus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ module.exports = async (tinyProduct, storeId, auth, isNew = true, tipo, appData)
136136
product.min_quantity = minQuantity
137137
}
138138
}
139-
if (tinyProduct.ncm && !appData.disable_ncm) {
139+
if (tinyProduct.ncm && !appData?.disable_ncm) {
140140
product.mpn = [tinyProduct.ncm]
141141
}
142142
const validateGtin = gtin => typeof gtin === 'string' && /^([0-9]{8}|[0-9]{12,14})$/.test(gtin)

functions/lib/integration/parsers/product-to-tiny-variation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module.exports = (ecomProduct, variation, originalTinyProduct, appData, storeId)
4646
tinyProduct.garantia = product.warranty.substring(0, 20)
4747
}
4848

49-
if (product.mpn && product.mpn.length && !appData.disable_ncm) {
49+
if (product.mpn && product.mpn.length && !appData?.disable_ncm) {
5050
tinyProduct.ncm = product.mpn[0]
5151
}
5252
if (product.gtin && product.gtin.length) {

functions/lib/integration/parsers/product-to-tiny.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = (product, originalTinyProduct, appData, storeId) => {
4040
tinyProduct.garantia = product.warranty.substring(0, 20)
4141
}
4242

43-
if (product.mpn && product.mpn.length && !appData.disable_ncm) {
43+
if (product.mpn && product.mpn.length && !appData?.disable_ncm) {
4444
tinyProduct.ncm = product.mpn[0]
4545
}
4646
if (product.gtin && product.gtin.length) {

0 commit comments

Comments
 (0)