Created
July 22, 2022 17:20
-
-
Save IliasHad/98bae9da0be73bcc392f54f00b4bf718 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const products = []; // products Array that will be in Shopify bulk import data after converting it to JSONL and uploading it | |
const getProductDetails = (product) => { | |
// using function to get data from somewhere | |
// we have the data needed to create the product | |
// the product param will be an object holding the product data | |
let data = { | |
media: [], | |
input: { | |
title: product.title, | |
descriptionHtml: product.descriptionHtml, | |
barcode: product.barcode, | |
variants: [], | |
options: [], | |
handle: product.handle, | |
tags: product.tags, | |
published: true, // make published from the first time | |
}, | |
}; | |
data.variant = product.variants.map((variant, index) => { | |
data.media.push({ | |
mediaContentType: "IMAGE", | |
originalSource: variant.publicImageUrl, | |
}); | |
return { | |
mediaSrc: [variant.publicImageUrl], | |
price: variant.price, | |
compareAtPrice: variant.compareAtPrice, | |
weight: variant.weight, | |
sku: variant.sku, | |
position: index, | |
}; | |
}); | |
products.push(data); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment