open-api icon indicating copy to clipboard operation
open-api copied to clipboard

[BUG]: updatingListingInventory wiping out variations

Open mmowchan opened this issue 3 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

It appears as though when using the updateListingInventory API to send an inventory update for a listing that includes variations or has multiple skus, 1 sku is wiping out the variations instead of inventory updates going back for all skus. Please see below the endpoint and request body we are attempting.

Endpoint: https://openapi.etsy.com/v3/application/listings/1146172724/inventory Request Body: { "products": [ { "sku": "bge", "offerings": [ { "price": 0.2, "quantity": 3, "is_enabled": true } ] }, { "sku": "blk", "offerings": [ { "price": 0.25, "quantity": 2, "is_enabled": true } ] } ] }

The listing we were trying to update (1146172724) had 2 variations/skus tied to it (blk and bge). After sending the inventory update listed above, all variations were wiped out and removed from the listing in Etsy and only blk was showing as the listing sku.

Is this expected behavior?

Steps to reproduce

  1. Create a listing with at least 2 variations, each with its own sku
  2. Update inventory for the variations via the updateListingInventory call (as outlined in example request body above)
  3. Check the listing in Etsy, see the variations have been wiped out and there is only one sku for the entire listing

Expected behavior

The variations have been wiped out and there is only one sku for the entire listing

Additional context

No response

mmowchan avatar Jan 18 '22 16:01 mmowchan

Your posted inventory is missing some critical information. See the tutorial here: https://developers.etsy.com/documentation/tutorials/listings#handling-variations-in-inventory-updates

If you look at the long sample code in the PHP Curl tab in this section, you'll see we are updating a product with variations that affect the skus. Because of this, the json data that you submit to the API must include all variations AND the following three fields (where x, y and z are the property ids that affect those values):

        "price_on_property": [x],
        "quantity_on_property": [y],
        "sku_on_property": [z]

In the example you provided price_on_property and quantity_on_property would be empty arrays ([]). But sku_on_property should have the property id. For color I believe that's 200.

Additionally, I don't see a "property_values" array for each variation. You do have the "offerings" array but the property values is missing.

Hope that helps!

etsyachristensen avatar Jan 20 '22 18:01 etsyachristensen