Tổng đài hỗ trợ - 
1900 6750
( 7:00 - 22:00 )

api-reference
tai-lieu-api
tai-lieu-nha-phat-trien

Phương thức PUT của Product

PUT/admin/products/632910392.json

Cập nhật một Product cùng các variant và ảnh liên quan

Cập nhật tên Product

PUT /admin/products/#{id}.json
{
  "product": {
    "id": 632910392,
    "name": "New product name"
  }
}
Xem kết quả

Cập nhật Product, xóa ảnh

PUT /admin/products/#{id}.json
{
  "product": {
    "id": 632910392,
    "images": [
    ]
  }
}
Xem kết quả

Cập nhật Tag của Product

PUT /admin/products/#{id}.json
{
  "product": {
    "id": 632910392,
    "tags": "Barnes & Noble, John's Fav"
  }
}
Xem kết quả

Cập nhật Product, sắp xếp lại thứ tự ảnh

PUT /admin/products/#{id}.json
{
  "product": {
    "id": 632910392,
    "images": [
      {
        "id": 850703190,
        "position": 2
      },
      {
        "id": 562641783,
        "position": 1
      }
    ]
  }
}
Xem kết quả

Cập nhật Product, thêm mới một ảnh

PUT /admin/products/#{id}.json
{
  "product": {
    "id": 632910392,
    "images": [
      {
        "id": 850703190
      },
      {
        "id": 562641783
      },
      {
        "src": "http:\/\/example.com\/rails_logo.gif"
      }
    ]
  }
}
Xem kết quả

Cập nhật Product và Variant

PUT /admin/products/#{id}.json
{
  "product": {
    "id": 632910392,
    "name": "Updated Product Title",
    "content": "<p>It's the small iPod with one very big idea: Video. Now the world's most popular music player, available in 4GB and 8GB models, lets you enjoy TV shows, movies, video podcasts, and more. The larger, brighter display means amazing picture quality. In six eye-catching colors, iPod nano is stunning all around. And with models starting at just $149, little speaks volumes.<\/p>",
    "summary": "It's the small iPod with one very big idea: Video.",
    "vendor": "Apple",
    "product_type": "Cult Products",
    "created_on": "2015-12-08T11:40:19Z",
    "alias": "ipod-nano",
    "modified_on": "2015-12-08T11:40:19Z",
    "published_on": "2007-12-31T19:00:00Z",
    "template_layout": null,
    
    "tags": "Emotive, Flash Memory, MP3, Music",
    "variants": [
      {
        "id": 808950810,
        "title": "Pink",
        "price": "2000.00",
        "sku": "Updating the Product SKU",
        "position": 1,
        "grams": 200,
        "inventory_policy": "continue",
        "compare_at_price": null,
        
        "inventory_management": "bizweb",
        "option1": "Pink",
        "option2": null,
        "option3": null,
        "created_on": "2015-12-08T11:40:19Z",
        "modified_on": "2015-12-08T11:40:19Z",
        "requires_shipping": true,
        
        "barcode": "1234_pink",
        "inventory_quantity": 10,
        
        "image_id": 562641783,
        "weight": 0.2,
        "weight_unit": "kg"
      },
      {
        "id": 49148385,
        "title": "Red",
        "price": "199.00",
        "sku": "IPOD2008RED",
        "position": 2,
        "grams": 200,
        "inventory_policy": "continue",
        "compare_at_price": null,
        
        "inventory_management": "bizweb",
        "option1": "Red",
        "option2": null,
        "option3": null,
        "created_on": "2015-12-08T11:40:19Z",
        "modified_on": "2015-12-08T11:40:19Z",
        "requires_shipping": true,
        
        "barcode": "1234_red",
        "inventory_quantity": 20,
        
        "image_id": null,
        "weight": 0.2,
        "weight_unit": "kg"
      },
      {
        "id": 39072856,
        "title": "Green",
        "price": "199.00",
        "sku": "IPOD2008GREEN",
        "position": 3,
        "grams": 200,
        "inventory_policy": "continue",
        "compare_at_price": null,
        
        "inventory_management": "bizweb",
        "option1": "Green",
        "option2": null,
        "option3": null,
        "created_on": "2015-12-08T11:40:19Z",
        "modified_on": "2015-12-08T11:40:19Z",
        "requires_shipping": true,
        
        "barcode": "1234_green",
        "inventory_quantity": 30,
        
        "image_id": null,
        "weight": 0.2,
        "weight_unit": "kg"
      },
      {
        "id": 457924702,
        "title": "Black",
        "price": "199.00",
        "sku": "IPOD2008BLACK",
        "position": 4,
        "grams": 200,
        "inventory_policy": "continue",
        "compare_at_price": null,
        
        "inventory_management": "bizweb",
        "option1": "Black",
        "option2": null,
        "option3": null,
        "created_on": "2015-12-08T11:40:19Z",
        "modified_on": "2015-12-08T11:40:19Z",
        "requires_shipping": true,
        
        "barcode": "1234_black",
        "inventory_quantity": 40,
        
        "image_id": null,
        "weight": 0.2,
        "weight_unit": "kg"
      }
    ],
    "options": [
      {
        "id": 594680422,
        "product_id": 632910392,
        "name": "Color",
        "position": 1,
        "values": [
          "Pink",
          "Red",
          "Green",
          "Black"
        ]
      }
    ],
    "images": [
      {
        "id": 850703190,
        "position": 1,
        "created_on": "2015-12-08T11:40:19Z",
        "modified_on": "2015-12-08T11:40:19Z",
        "src": "https:\/\/bizweb.dktcdn.net\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano.png?v=1449592819",
        "variant_ids": [
        ]
      },
      {
        "id": 562641783,
        "position": 2,
        "created_on": "2015-12-08T11:40:19Z",
        "modified_on": "2015-12-08T11:40:19Z",
        "src": "https:\/\/bizweb.dktcdn.net\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano-2.png?v=1449592819",
        "variant_ids": [
          808950810
        ]
      }
    ],
    "image": {
      "id": 850703190,
      "position": 1,
      "created_on": "2015-12-08T11:40:19Z",
      "modified_on": "2015-12-08T11:40:19Z",
      "src": "https:\/\/bizweb.dktcdn.net\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano.png?v=1449592819",
      "variant_ids": [
      ]
    }
  }
}
Xem kết quả
HTTP/1.1 200 OK
{
  "product": {
    "id": 632910392,
    "name": "Updated Product Title",
    "content": "

It's the small iPod with one very big idea: Video. Now the world's most popular music player, available in 4GB and 8GB models, lets you enjoy TV shows, movies, video podcasts, and more. The larger, brighter display means amazing picture quality. In six eye-catching colors, iPod nano is stunning all around. And with models starting at just $149, little speaks volumes.<\/p>","summary": "It's the small iPod with one very big idea: Video.", "vendor": "Apple", "product_type": "Cult Products", "created_on": "2015-12-08T11:40:19Z", "alias": "ipod-nano", "modified_on": "2015-12-08T11:42:42Z", "published_on": "2007-12-31T19:00:00Z", "template_layout": null, "tags": "Emotive, Flash Memory, MP3, Music", "variants": [ { "id": 808950810, "product_id": 632910392, "title": "Pink", "price": "2000.00", "sku": "Updating the Product SKU", "position": 1, "grams": 200, "inventory_policy": "continue", "compare_at_price": null, "inventory_management": "bizweb", "option1": "Pink", "option2": null, "option3": null, "created_on": "2015-12-08T11:40:19Z", "modified_on": "2015-12-08T11:42:42Z", "requires_shipping": true, "barcode": "1234_pink", "inventory_quantity": 10, "image_id": 562641783, "weight": 0.2, "weight_unit": "kg" }, { "id": 49148385, "product_id": 632910392, "title": "Red", "price": "199.00", "sku": "IPOD2008RED", "position": 2, "grams": 200, "inventory_policy": "continue", "compare_at_price": null, "inventory_management": "bizweb", "option1": "Red", "option2": null, "option3": null, "created_on": "2015-12-08T11:40:19Z", "modified_on": "2015-12-08T11:40:19Z", "requires_shipping": true, "barcode": "1234_red", "inventory_quantity": 20, "image_id": null, "weight": 0.2, "weight_unit": "kg" }, { "id": 39072856, "product_id": 632910392, "title": "Green", "price": "199.00", "sku": "IPOD2008GREEN", "position": 3, "grams": 200, "inventory_policy": "continue", "compare_at_price": null, "inventory_management": "bizweb", "option1": "Green", "option2": null, "option3": null, "created_on": "2015-12-08T11:40:19Z", "modified_on": "2015-12-08T11:40:19Z", "requires_shipping": true, "barcode": "1234_green", "inventory_quantity": 30, "image_id": null, "weight": 0.2, "weight_unit": "kg" }, { "id": 457924702, "product_id": 632910392, "title": "Black", "price": "199.00", "sku": "IPOD2008BLACK", "position": 4, "grams": 200, "inventory_policy": "continue", "compare_at_price": null, "inventory_management": "bizweb", "option1": "Black", "option2": null, "option3": null, "created_on": "2015-12-08T11:40:19Z", "modified_on": "2015-12-08T11:40:19Z", "requires_shipping": true, "barcode": "1234_black", "inventory_quantity": 40, "image_id": null, "weight": 0.2, "weight_unit": "kg" } ], "options": [ { "id": 594680422, "product_id": 632910392, "name": "Color", "position": 1, "values": [ "Pink", "Red", "Green", "Black" ] } ], "images": [ { "id": 850703190, "product_id": 632910392, "position": 1, "created_on": "2015-12-08T11:40:19Z", "modified_on": "2015-12-08T11:40:19Z", "src": "https:\/\/bizweb.dktcdn.net\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano.png?v=1449592819", "variant_ids": [ ] }, { "id": 562641783, "product_id": 632910392, "position": 2, "created_on": "2015-12-08T11:40:19Z", "modified_on": "2015-12-08T11:40:19Z", "src": "https:\/\/bizweb.dktcdn.net\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano-2.png?v=1449592819", "variant_ids": [ 808950810 ] } ], "image": { "id": 850703190, "product_id": 632910392, "position": 1, "created_on": "2015-12-08T11:40:19Z", "modified_on": "2015-12-08T11:40:19Z", "src": "https:\/\/bizweb.dktcdn.net\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano.png?v=1449592819", "variant_ids": [ ] } } }

Thêm metafield vào một Product

PUT /admin/products/#{id}.json
{
  "product": {
    "id": 632910392,
    "metafields": [
      {
        "key": "new",
        "value": "newvalue",
        "value_type": "string",
        "namespace": "global"
      }
    ]
  }
}
Xem kết quả


Bài viết trên có hữu ích cho bạn không?

Hữu ích Không hữu ích
Số lượt đánh giá hữu ích: