4

Trying to Change only the price of the products with PUT method.

HERE http://devdocs.magento.com/guides/m1x/api/rest/Resources/Products/products.html#RESTAPI-Resource-Products-HTTPMethod-PUT-products--id

is stated that this is possible! But When i make a call with only the price in the product array i get a response like

    Array
(
    [message] => Invalid product data: %1
    [parameters] => Array
        (
            [0] => Invalid attribute set entity type
        )

)

So i add attribute set adn then i get the response

Array
(
    [message] => The value of attribute "name" must be set
)

On the magento link here http://devdocs.magento.com/guides/m1x/api/rest/Resources/Products/products.html#RESTAPI-Resource-Products-HTTPMethod-PUT-products--id

Says that this should be possible with no other params

Enter only those parameters which you want to update.

Any ideas why is this happening?

the call i am using PUT /rest/V1/products/:sku

1 Answer 1

5

You can use the following rest PUT call:

/rest/V1/products/{SKU}

Passing the following json:

{
"product": {
  "price": 9.63,
  "extension_attributes": {
    "stock_item": {
      "qty": 63
    }
  }
 }
}

So you can update price and stock quantity with one single call. You can remove the extension_attributes value, if you only want to update the price.

EDIT

You will need a quotation mark for your price, like this below. I don't quite understand why because the price should be a double variable in the database.

{ 
    "product":{ 
        "price":"9.63",
        "extension_attributes":{ 
            "stock_item":{ 
                "qty":63
            }
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.