Python API to edit a product options

Simom_l
New Member
1 0 0

Hi,

  I try to edit a product options by Python API. According to this thread, my code is like following:

new_product.options = [
{
'name': 'bounding_box',
'values': [
product.bb_top, product.bb_bottom,
product.bb_left, product.bb_right
]
},
{'name': 'centroid', 'values': [centroid]}
]

where new product is the product return from find() API, and product is our product object.

However, when next time I retrieve from the get API, the options is still remain same.

Two API response are list as following, the first one is get, notice in here, the options are "default title":

{
   "product":{
      "id":5494873030812,
      "title":"Lac Bambou (La V\\xc3\\xa9rendrye)",
      "body_html":"Carte de lac de la S\\xc3\\xa9paq. Selon les donn\\xc3\\xa9es disponibles, la carte peut pr\\xc3\\xa9senter diverses informations telles que la bathym\\xc3\\xa9trie ou les sites favorables \\xc3\\xa0 la p\\xc3\\xaache.",
      "vendor":"S\\xc3\\xa9paq",
      "product_type":"digital map",
      "created_at":"2020-08-12T00:15:48-03:00",
      "handle":"lac-bambou-la-verendrye-1116505",
      "updated_at":"2020-09-14T12:21:58-03:00",
      "published_at":"2020-05-07T21:00:00-03:00",
      "template_suffix":null,
      "published_scope":"web",
      "tags":"activity:Backroading, activity:Hiking, cat:Hunting \\u0026 Fishing, cat:Recreation, cty:Canada, dld_time:5, lang:French",
      "admin_graphql_api_id":"gid:\\/\\/shopify\\/Product\\/5494873030812",
      "variants":[
         {
            "id":35993904545948,
            "product_id":5494873030812,
            "title":"Default Title",
            "price":"0.00",
            "sku":"1116505",
            "position":1,
            "inventory_policy":"continue",
            "compare_at_price":null,
            "fulfillment_service":"manual",
            "inventory_management":null,
            "option1":"Default Title",
            "option2":null,
            "option3":null,
            "created_at":"2020-09-14T12:21:57-03:00",
            "updated_at":"2020-09-14T12:21:57-03:00",
            "taxable":true,
            "barcode":null,
            "grams":0,
            "image_id":null,
            "weight":0.0,
            "weight_unit":"kg",
            "inventory_item_id":38043204649116,
            "inventory_quantity":0,
            "old_inventory_quantity":0,
            "requires_shipping":false,
            "admin_graphql_api_id":"gid:\\/\\/shopify\\/ProductVariant\\/35993904545948"
         }
      ],
      "options":[
         {
            "id":7025473388700,
            "product_id":5494873030812,
            "name":"Title",
            "position":1,
            "values":[
               "Default Title"
            ]
         }
      ],
      "images":[
         {
            "id":19071611338908,
            "product_id":5494873030812,
            "position":1,
            "created_at":"2020-09-14T12:21:57-03:00",
            "updated_at":"2020-09-14T12:21:57-03:00",
            "alt":null,
            "width":756,
            "height":459,
            "src":"https:\\/\\/cdn.shopify.com\\/s\\/files\\/1\\/0441\\/7850\\/5884\\/products\\/20200508133711_LVY_Carte_Lac_Bambou_preview_0_80cb137e-4252-4238-8e50-516a87955812.jpg?v=1600096917",
            "variant_ids":[
               
            ],
            "admin_graphql_api_id":"gid:\\/\\/shopify\\/ProductImage\\/19071611338908"
         },
         {
            "id":19071611371676,
            "product_id":5494873030812,
            "position":2,
            "created_at":"2020-09-14T12:21:57-03:00",
            "updated_at":"2020-09-14T12:21:57-03:00",
            "alt":null,
            "width":512,
            "height":512,
            "src":"https:\\/\\/cdn.shopify.com\\/s\\/files\\/1\\/0441\\/7850\\/5884\\/products\\/20200508133711_LVY_Carte_Lac_Bambou_preview_1_f8fde83d-0a2d-4ec8-9451-e78b86cbca02.jpg?v=1600096917",
            "variant_ids":[
               
            ],
            "admin_graphql_api_id":"gid:\\/\\/shopify\\/ProductImage\\/19071611371676"
         },
         {
            "id":19071611404444,
            "product_id":5494873030812,
            "position":3,
            "created_at":"2020-09-14T12:21:57-03:00",
            "updated_at":"2020-09-14T12:21:57-03:00",
            "alt":null,
            "width":512,
            "height":512,
            "src":"https:\\/\\/cdn.shopify.com\\/s\\/files\\/1\\/0441\\/7850\\/5884\\/products\\/20200508133711_LVY_Carte_Lac_Bambou_preview_2_87ab51b5-a370-4159-afcd-6c8c8a41f8dd.jpg?v=1600096917",
            "variant_ids":[
               
            ],
            "admin_graphql_api_id":"gid:\\/\\/shopify\\/ProductImage\\/19071611404444"
         }
      ],
      "image":{
         "id":19071611338908,
         "product_id":5494873030812,
         "position":1,
         "created_at":"2020-09-14T12:21:57-03:00",
         "updated_at":"2020-09-14T12:21:57-03:00",
         "alt":null,
         "width":756,
         "height":459,
         "src":"https:\\/\\/cdn.shopify.com\\/s\\/files\\/1\\/0441\\/7850\\/5884\\/products\\/20200508133711_LVY_Carte_Lac_Bambou_preview_0_80cb137e-4252-4238-8e50-516a87955812.jpg?v=1600096917",
         "variant_ids":[
            
         ],
         "admin_graphql_api_id":"gid:\\/\\/shopify\\/ProductImage\\/19071611338908"
      }
   }
}

 

{
   "product":{
      "id":5494873030812,
      "title":"Lac Bambou (La V\\u00e9rendrye)",
      "body_html":"Carte de lac de la S\\u00e9paq. Selon les donn\\u00e9es disponibles, la carte peut pr\\u00e9senter diverses informations telles que la bathym\\u00e9trie ou les sites favorables \\u00e0 la p\\u00eache.",
      "vendor":"S\\u00e9paq",
      "product_type":"digital map",
      "created_at":"2020-08-12T00:15:48-03:00",
      "handle":"lac-bambou-la-verendrye-1116505",
      "updated_at":"2020-09-14T12:21:58-03:00",
      "published_at":"2020-05-08",
      "template_suffix":null,
      "published_scope":"web",
      "tags":"cat:Recreation,cat:Hunting & Fishing,cty:Canada,lang:French,dld_time:5,,,",
      "admin_graphql_api_id":"gid://shopify/Product/5494873030812",
      "variants":[
         {
            "requires_shipping":false,
            "sku":1116505,
            "fulfillment_service":"manual",
            "price":0,
            "inventory_policy":"continue",
            "taxable":true,
            "tracked":false
         }
      ],
      "options":[
         {
            "name":"bounding_box",
            "values":[
               47.67047017395957,
               47.659241159856,
               -76.69597719202004,
               -76.66719165402108
            ]
         },
         {
            "name":"centroid",
            "values":[
               "POINT (-76.68158442302057 47.66485566690778)"
            ]
         }
      ],
      "images":[
         {
            "src":"https://s3.amazonaws.com/com-avenza-heroku-mapstore-production/VendorMaps/2898/20200508133711_LVY_Carte_Lac_Bambou_preview_0.jpg",
            "position":1
         },
         {
            "src":"https://s3.amazonaws.com/com-avenza-heroku-mapstore-production/VendorMaps/2898/20200508133711_LVY_Carte_Lac_Bambou_preview_1.jpg",
            "position":2
         },
         {
            "src":"https://s3.amazonaws.com/com-avenza-heroku-mapstore-production/VendorMaps/2898/20200508133711_LVY_Carte_Lac_Bambou_preview_2.jpg",
            "position":3
         }
      ],
      "image":{
         "id":19071611338908,
         "position":1,
         "created_at":"2020-09-14T12:21:57-03:00",
         "updated_at":"2020-09-14T12:21:57-03:00",
         "alt":null,
         "width":756,
         "height":459,
         "src":"https://cdn.shopify.com/s/files/1/0441/7850/5884/products/20200508133711_LVY_Carte_Lac_Bambou_preview_0_80cb137e-4252-4238-8e50-516a87955812.jpg?v=1600096917",
         "variant_ids":[
            
         ],
         "admin_graphql_api_id":"gid://shopify/ProductImage/19071611338908"
      },
      "price":0
   }
}

Thanks in advanced,

Simon

0 Likes