Answers for "add product variant shopify python API"

0

add product variant shopify python API

new_product = shopify.Product()
new_product.title = "My Product"
new_product.handle = "test-product"

##what I've tried... and countless others
#First example of new_product.variants
new_product.variants = shopify.Variant({'options': {'option1' : ['S', 'M', 'L', 'XL'], 'option2' : ['Black', 'Blue', 'Green', 'Red']}, 'product_id': '123456789'})
#Second example of new_product.variants
new_product.variants = shopify.Variant({'options': [{'option1': 'Size', 'option2': 'Colour','option3': 'Material'}]})
#Thrid example of new_product.variants
new_product.variants = shopify.Variant([
                      {'title':'v1', 'option1': 'Red', 'option2': 'M'},
                      {'title':'v2', 'option1' :'Blue', 'option2' :'L'}
                      ])
new_product.save()
##No errors are output, but doesn't create variants with options
if new_product.errors:
    print new_product.errors.full_messages()
print "Done"
Posted by: Guest on June-21-2021

Python Answers by Framework

Browse Popular Code Answers by Language