使用python api在shopify中创建带有图像URL的新产品

May*_*ain 5 python shopify

我希望从现有的网络应用程序自动将商品发布到shopify商店.我需要能够使用图像创建项目.我已经能够通过python api在shopify上创建项目 - 但我不确定如何添加图像.这就是我现在所拥有的:

all_products = Product.objects.all()[0:7]
for p in all_products:
    images=[]
    image={}
    image["src"] = p.image.url

    new_product = shopify.Product()
    new_product.product_type = p.category()
    new_product.body_html = p.description
    new_product.title = p.caption
    new_product.vendor = "atisundar"
    new_product.images = images
    new_product.save()
Run Code Online (Sandbox Code Playgroud)

如何向此添加图像?

new_product.images似乎不起作用.

非常感谢任何和所有的帮助.:-)

谢谢.

May*_*ain 5

我想到了.:-)

    new_product = shopify.Product()
    new_product.product_type = p.category()
    new_product.body_html = p.description
    new_product.title = "atisundar "+ p.caption
    new_product.vendor = "atisundar"

    image1 = shopify.Image()
    image1.src = p.image.url()

    new_product.images = [image1]
    new_product.save()
Run Code Online (Sandbox Code Playgroud)