FROM CACHE - en_header

Creating a product

CS23
New Member
1 0 0

I am having a issue with creating a product, when I create the product the price or quantity does not get published like the rest of the attributes shown. I've included my code (python). Can anyone help pls?

import shopify

API_KEY = ''
PASSWORD = ''
SHOP_NAME = ''

shop_url = "https://SHOP.myshopify.com/admin"
shopify.ShopifyResource.set_user(API_KEY)
shopify.ShopifyResource.set_password(PASSWORD)
shopify.ShopifyResource.set_site(shop_url)
shop = shopify.Shop.current()

new_product = shopify.Product()
new_product.title = "title"
new_product.body_html = "test"
new_product.price = 19.99
new_product.quantity = 1
new_product.save()
new_image = shopify.Image(dict(product_id=new_product.id))
new_image.src=""
new_image.save()
Reply 1 (1)
TINA_CORREA
Shopify Partner
4 0 1

https://help.shopify.com/en/api/reference/products/product#create

 

Check link above. If you see the response of API, price and quantity are the Variant level. 

Even if a product has no size/color variations , it still needs a default variant.

 

You are sending price and quantity at the product level . it has to be sent at the Variant level

 

"product": {
    "variants": [
      {
       
        "price": "0.00",