inakiabt / etsy-php

Etsy API wrapper for PHP
74 stars 59 forks source link

Issues with updating inventory #29

Open keyurshah opened 7 years ago

keyurshah commented 7 years ago

Thanks for the amazing library!

I first am creating a listing using the createListing method.

I am then trying to add inventory using the updateInventory method, but am getting errors about invalid param type

Invalid params for method "updateInventory": Invalid data param type "products"

If anyone has a sample of the final structure that I need to have in php to use the updateInventory method, that would be very helpful. This is not working for me.

        $etsy_listing_id = 999999999; //during testing, using a real listing id
        $primary_colors_id = 200;

        $colors = [
            [
                'property_id'   => $primary_colors_id,
                'property_name' => 'Primary color',
                'value_ids'     => [1213],
                'values'        => ['Beige'],
            ],
        ];

        $products =
            [
                [
                    'property_values' => [$colors[0]],
                    'sku'       => 'A-800',
                    'offerings' => [
                        [
                            'price'      => 15.00,
                            'quantity'   => 4,
                            'is_enabled' => 1,
                        ],
                    ],
                ],
            ];

        $data = [
            'params' => [
                'listing_id' => $etsy_listing_id,
            ],
            'data' => [
                'products' => json_encode($products),
                "price_on_property" => [$primary_colors_id],
                "quantity_on_property" => [$primary_colors_id],
                "sku_on_property" => [$primary_colors_id],
            ],
        ];

        $etsy_inventory_items = $this->etsy_api->updateInventory($data);

Thank You

keyurshah commented 7 years ago

I was able to get it to work, but I had to edit the methods.json line and change stringJSON to string

line 761 "products": "string",

I know there is a pending pull request, so not sure what is the correct way to get this to work.

Thanks.

27

magefast commented 3 years ago

@keyurshah I agree, after change to type "string" - all works

Thanks @keyurshah