Shopify API uploading product error when more than one option is selected

时间:2016-04-04 19:01:34

标签: shopify

I am trying to integrate our company's software to Shopify. Everything looks fine except when I am trying to send product to Shopify that has more than one Option (i.e. "Size" with variants "S, M, L" & "Color" with variants "RED, BLUE, GREEN").

This is the error message.

(If I have just one Option it works fine).

Here is a sample XML file :

{
  "product": {
    "id": 0,
    "handle": "AMIN",
    "sku": "AMIN",
    "body_html": "",
    "product_type": "BULK",
    "title": "AMIN",
    "vendor": null,
    "variants": [
      {
        "id": 0,
        "barcode": null,
        "grams": 0.0,
        "option1": "S",
        "option2": "YELLOW",
        "option3": null,
        "price": 12.0000,
        "inventory_quantity": 1,
        "product_id": 0,
        "sku": "AMIN-SY",
        "weight": 0.0,
        "weight_unit": null,
        "image_id": null,
        "taxable": true,
        "title": "S YELLOW",
        "requires_shipping": true,
        "compare_at_price": 12.0000,
        "position": 1
      },
      {
        "id": 0,
        "barcode": null,
        "grams": 0.0,
        "option1": "S",
        "option2": "RED",
        "option3": null,
        "price": 12.0000,
        "inventory_quantity": 1,
        "product_id": 0,
        "sku": "AMIN-SR",
        "weight": 0.0,
        "weight_unit": null,
        "image_id": null,
        "taxable": true,
        "title": "S RED",
        "requires_shipping": true,
        "compare_at_price": 12.0000,
        "position": 2
      },
      {
        "id": 0,
        "barcode": null,
        "grams": 0.0,
        "option1": "S",
        "option2": "BLUE",
        "option3": null,
        "price": 12.0000,
        "inventory_quantity": 1,
        "product_id": 0,
        "sku": "AMIN-SB",
        "weight": 0.0,
        "weight_unit": null,
        "image_id": null,
        "taxable": true,
        "title": "S BLUE",
        "requires_shipping": true,
        "compare_at_price": 12.0000,
        "position": 3
      },
      {
        "id": 0,
        "barcode": null,
        "grams": 0.0,
        "option1": "M",
        "option2": "YELLOW",
        "option3": null,
        "price": 12.0000,
        "inventory_quantity": 1,
        "product_id": 0,
        "sku": "AMIN-MY",
        "weight": 0.0,
        "weight_unit": null,
        "image_id": null,
        "taxable": true,
        "title": "M YELLOW",
        "requires_shipping": true,
        "compare_at_price": 12.0000,
        "position": 4
      },
      {
        "id": 0,
        "barcode": null,
        "grams": 0.0,
        "option1": "M",
        "option2": "RED",
        "option3": null,
        "price": 12.0000,
        "inventory_quantity": 2,
        "product_id": 0,
        "sku": "AMIN-MR",
        "weight": 0.0,
        "weight_unit": null,
        "image_id": null,
        "taxable": true,
        "title": "M RED",
        "requires_shipping": true,
        "compare_at_price": 12.0000,
        "position": 5
      },
      {
        "id": 0,
        "barcode": null,
        "grams": 0.0,
        "option1": "M",
        "option2": "BLUE",
        "option3": null,
        "price": 12.0000,
        "inventory_quantity": 1,
        "product_id": 0,
        "sku": "AMIN-MB",
        "weight": 0.0,
        "weight_unit": null,
        "image_id": null,
        "taxable": true,
        "title": "M BLUE",
        "requires_shipping": true,
        "compare_at_price": 12.0000,
        "position": 6
      },
      {
        "id": 0,
        "barcode": null,
        "grams": 0.0,
        "option1": "LARGE",
        "option2": "YELLOW",
        "option3": null,
        "price": 12.0000,
        "inventory_quantity": 1,
        "product_id": 0,
        "sku": "AMIN-LY",
        "weight": 0.0,
        "weight_unit": null,
        "image_id": null,
        "taxable": true,
        "title": "LARGE YELLOW",
        "requires_shipping": true,
        "compare_at_price": 12.0000,
        "position": 7
      },
      {
        "id": 0,
        "barcode": null,
        "grams": 0.0,
        "option1": "LARGE",
        "option2": "RED",
        "option3": null,
        "price": 12.0000,
        "inventory_quantity": 1,
        "product_id": 0,
        "sku": "AMIN-LR",
        "weight": 0.0,
        "weight_unit": null,
        "image_id": null,
        "taxable": true,
        "title": "LARGE RED",
        "requires_shipping": true,
        "compare_at_price": 12.0000,
        "position": 8
      },
      {
        "id": 0,
        "barcode": null,
        "grams": 0.0,
        "option1": "LARGE",
        "option2": "BLUE",
        "option3": null,
        "price": 12.0000,
        "inventory_quantity": 3,
        "product_id": 0,
        "sku": "AMIN-LB",
        "weight": 0.0,
        "weight_unit": null,
        "image_id": null,
        "taxable": true,
        "title": "LARGE BLUE",
        "requires_shipping": true,
        "compare_at_price": 12.0000,
        "position": 9
      }
    ],
    "options": null,
    "images": null,
    "tags": null
  }
}

1 个答案:

答案 0 :(得分:0)

当您提供变体时,您必须在产品对象中提及选项。

"options": null,更改为

"options":[{"name":"Size","position":1},{"name":"Color","position":2}],

同时从 中移除idproduct_idoption3,从产品移除id。 Shopify将自动分配 ID