#Please Help With Loader
5 messages · Page 1 of 1 (latest)
If you log the product after you've made it. What is the output?
No product is being made, the code somehow doesn’t make it that far, that is why I’m confused. By the time we get to ‘console.log({existingProduct})’, nothing is logged, and nothing is happening.
// ... map the item fields to the product fields
const product = {id: item.itemID, ...etc};
What is your actual code here?
Seems to me like you try to create the product with non existing variables or faulty ones
@river crow I see, but I'd expect an error telling me there was an issue with 'product'? Do you see any issues below? I appreciate your help with this.
Here's my code for the product:
for (const item of items) {
console.log(`Item of items: `, item.itemID) // This gets logged
// ... map the item fields to the product field
const product = {
id: item.itemID,
title: item.description,
description: `${shortDescription} ${longDescription}`,
status: "published",
mid_code: item.manufacturerSku,
images: item.Images?.Image.map((image) => ({
id: image.imageID,
url: `${item.Images.Image[0].baseImageURL}/w_2000/${item.Images.Image[0].filename}.avif`,
})),
thumbnail: `${item.Images.Image[0].baseImageURL}/w_500/${item.Images.Image[0].filename}.avif`,
allow_backorder: isOnBackorder,
categories: [
{
id: item.Category.categoryID,
name: item.Category.name,
parent_category_id: item.Category.parentID,
rank: item.Category.nodeDepth,
},
],
variants: [
{
product_id: item.itemID,
title: item.description,
sku: item.customSku,
ean: item.upc,
barcode: item.ean,
inventory_quantity: item.qoh,
prices: [
{
amount: item.price
? Math.round(item.price * 100)
: Math.round(item.Prices.ItemPrice[0].amount * 100),
allow_backorder: false,
currency_code: "GBP",
},
],
},
],
};
console.log({product}) // Nothing logged to the console
I've also tried logging product just underneath, no console log 🤷♂️