Python post products with variants from csv to shopify api

128 Views Asked by At

i have the following problem. I want to import products to Shopify using the API. The body of the request should look like this:

{
"product": {
    "id": "100",
    "title": "Burton Custom Freestyle 151",
    "body_html": "<strong>Good snowboard!<\/strong>",
    "vendor": "Burton",
    "product_type": "Snowboard",
    "variants": [
    {
        "option1": "First",
        "price": "10.00",
        "sku": "1000"
    },
    {
        "option1": "Second",
        "price": "20.00",
        "sku": "1001"
    }
    ]
}
}
}

My CSV file now contains these values (of course the real one has a lot more values) example CSV

so every product should only contain one product id with the right variant id's. I don't have any clue how to loop through all rows and put them in the right format. The script should check if the product id is the same as in the row before and then add it as a variant to the product.

P.S: obviously i'm new to python and coding.

Thanks for any help in advance!

0

There are 0 best solutions below