3

Apologies if this is a silly question, I'm sure it must be but I just can't seem to figure out how you are supposed to add a product's description via REST.

The REST API docs at http://devdocs.magento.com/swagger/index_20.html under the catalogProductRepositoryV1 list all the the available fields but description is not there.

Can someone advise which resource the product's description is managed through?

1 Answer 1

3

We need to add custom_attributes:

$productData = [
        'attribute_set_id'  => 4,
        "type_id": "simple",
        "sku": "test-SKU",
        "name": "Test",
        "price": 100,
        "status": 1,
        'custom_attributes' => [
                ['attribute_code' => 'description', 'value' => 'Test Description' ],
                ['attribute_code' => 'short_description', 'value' => 'Test Short Description' ],
            ]
    ];

Payload:

{
    "product": {
        "attribute_set_id": 4,
        "type_id": "simple",
        "sku": "test-SKU",
        "name": "Test",
        "price": 100,
        "status": 1,
        "custom_attributes": {
            "description": "Test Description",
            "short_description": "Test Short Description"
        }
    }
}
3
  • I believe that your JSON Payload field custom_attributes is wrong. It should possibly be "custom_attributes": [ {"attribute_code":"description","value":"Test Description",} , "attribute_code":"short_description","value":"Test Short Description"} ].
    – dotancohen
    Jul 15, 2019 at 14:08
  • @Khoa TruongDinh How to add selected attributes label in product rest API. Like ['attribute_code' => 'description', 'value' => 'Test Description', 'label' => 'Description' ], Sep 5, 2019 at 5:50

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.