1

I am trying to update my variations on a listing via this method...

listings/'.$listing_id.'/inventory

However, when I try to add a second SKU it gives me the error message that "SKU must be consistent across linked products."

I know it is possible to have a listingn with multiple SKUs in the variations because that is how we currently operate. We are just trying to move some functionality over to our Admin portal (i.e. changin the variations on listings).

Right now we use "Size" and "Sleeve Length" as varations.

I am able to create multiple "Sleeve Lengths" but when I try to add more than one size with a SKU, it errors out.

I have also linked a video here explaining the issue.

https://drive.google.com/file/d/1_dywrCfv0QjNzR2VyHqh5un7TXzuV5p8/view?usp=sharing

Any help that anyone can provide would be IMMENSELY appreciated.

This is the array I'm trying to send through.

$testarray=  array(
                  [
                    'sku' => 'sku-1',
                    'property_values' => [
                        [
                            'property_id' => '52047899318',
                            'property_name' => 'Size',
                            'scale_id' => 30,
                            'scale_name' => '',
                            'value' => '0-3M White Onesie',
                            'value_id' => '117126874336'
                        ],
                        [
                             'property_id' => '513',
                             'property_name' => 'Sleeve Length',
                             'value' => 'Short SL Onesie',
                             'value_id' => '774674484481'
                        ]
                    ],
                    'offerings' => [
                        [
                            'price' => 10,
                            'quantity' => 3
                        ]
                    ]
                 ],
                  [
                    'sku' => 'sku-2',
                    'property_values' => [
                        [
                            'property_id' => '52047899318',
                            'property_name' => 'Size',
                            'scale_id' => 30,
                            'scale_name' => '',
                            'value' => '0-3M White Onesie',
                            'value_id' => '117126874336'
                        ],
                        [
                             'property_id' => '513',
                             'property_name' => 'Sleeve Length',
                             'value' => 'Short SL Onesie',
                             'value_id' => '774674484481'
                        ]
                    ],
                    'offerings' => [
                        [
                            'price' => 10,
                            'quantity' => 3
                        ]
                    ]
                 ]);
  • I guess what your error message and the video that you shared suggests that there is some validation that won't let you add two things with different skus. Share the method of the controller that this route is linked to `listings/'.$listing_id.'/inventory`. – Aashish gaba Jul 23 '20 at 20:33
  • did you ever solve this? – amcquaid Mar 12 '21 at 12:04

1 Answers1

4

I know that this question is 2 years old but since I came across the same error while implementing Etsy api I wanted help the others by posting my findings.

Suppose your items have the following variations

Size: 
    M
    L
Sleeve Length: 
    Long
    Short

First thing that you have to know is that when sending property values you MUST send all the possible combinations. What that means is the following:

Size M -> Sleeve Length Long

Size M -> Sleeve Length Short

Size L -> Sleeve Length Long

Size L -> Sleeve Length Short

This is how will look like in your products array, notice how I omitted the skus for now:

[
    {
        "property_values": [
            {
                "property_id": "52047899318",
                "property_name": "Size",
                "value": "M"
            },
            {
                "property_id": "513",
                "property_name": "Sleeve Length",
                "value": "Short"
            }
        ]
    },
    {
        "property_values": [
            {
                "property_id": "52047899318",
                "property_name": "Size",
                "value": "M"
            },
            {
                "property_id": "513",
                "property_name": "Sleeve Length",
                "value": "Long"
            }
        ]
    },
    {
        "property_values": [
            {
                "property_id": "52047899318",
                "property_name": "Size",
                "value": "L"
            },
            {
                "property_id": "513",
                "property_name": "Sleeve Length",
                "value": "Short"
            }
        ]
    },
    {
        "property_values": [
            {
                "property_id": "52047899318",
                "property_name": "Size",
                "value": "L"
            },
            {
                "property_id": "513",
                "property_name": "Sleeve Length",
                "value": "Long"
            }
        ]
    }
]

Now, regarding skus suppose that we have the following:

sku-1 refers to Size M Sleeve Length Short

sku-2 refers to Size L Sleeve Length Long

We have no sku for Size M Sleeve Length Long and Size L Sleeve Length Short

Keeping that in mind our array will now look like this:

[
    {
        "sku": "sku-1",
        "property_values": [
            {
                "property_id": "52047899318",
                "property_name": "Size",
                "value": "M"
            },
            {
                "property_id": "513",
                "property_name": "Sleeve Length",
                "value": "Short"
            }
        ]
    },
    {
        "sku": "",
        "property_values": [
            {
                "property_id": "52047899318",
                "property_name": "Size",
                "value": "M"
            },
            {
                "property_id": "513",
                "property_name": "Sleeve Length",
                "value": "Long"
            }
        ]
    },
    {
        "sku": "",
        "property_values": [
            {
                "property_id": "52047899318",
                "property_name": "Size",
                "value": "L"
            },
            {
                "property_id": "513",
                "property_name": "Sleeve Length",
                "value": "Short"
            }
        ]
    },
    {
        "sku": "sku-2",
        "property_values": [
            {
                "property_id": "52047899318",
                "property_name": "Size",
                "value": "L"
            },
            {
                "property_id": "513",
                "property_name": "Sleeve Length",
                "value": "Long"
            }
        ]
    }
]

Last thing we have to do, since our sku is changing from variation to variation in our case it changes based on size and sleeve length, before sending data we have to tell etsy that the sku is changing depending on the property, and to do that we have to set the sku_on_property property.

In our case the sku changes based on property id 52047899318 and 513.

Basically our request body will look like this:

{
    "products": [
        {
            "sku": "sku-1",
            "property_values": [
                {
                    "property_id": "52047899318",
                    "property_name": "Size",
                    "value": "M"
                },
                {
                    "property_id": "513",
                    "property_name": "Sleeve Length",
                    "value": "Short"
                }
            ]
        },
        {
            "sku": "",
            "property_values": [
                {
                    "property_id": "52047899318",
                    "property_name": "Size",
                    "value": "M"
                },
                {
                    "property_id": "513",
                    "property_name": "Sleeve Length",
                    "value": "Long"
                }
            ]
        },
        {
            "sku": "",
            "property_values": [
                {
                    "property_id": "52047899318",
                    "property_name": "Size",
                    "value": "L"
                },
                {
                    "property_id": "513",
                    "property_name": "Sleeve Length",
                    "value": "Short"
                }
            ]
        },
        {
            "sku": "sku-2",
            "property_values": [
                {
                    "property_id": "52047899318",
                    "property_name": "Size",
                    "value": "L"
                },
                {
                    "property_id": "513",
                    "property_name": "Sleeve Length",
                    "value": "Long"
                }
            ]
        }
    ],
    "sku_on_property": [
        52047899318,
        513
    ]
}

I hope that at least this comment will be helpful to everyone that comes across this thread.

Small things that you have to keep in mind:

  • this is for Etsy api v3, if you work with etsy api v2, I think that the sku_on_property should be a comma separated string instead of an array of integers, example: "sku_on_property":"52047899318,513"

  • If your price and/or quantity changes based on the variations, then you have to set also the property price_on_property and quantity_on_property respectively in the same way you did for the skus.

Garantees
  • 41
  • 2