Create product with custom option (Field type ) using rest api not saving
-
16-04-2021 - |
Question
I am trying to create simple product with custom option(Field type) using rest api but custom option is not saving with product endpoint rest/V1/products
.
request body
{
"product": {
"sku": "test_simple_product3",
"name": "Test Simple Product",
"attribute_set_id": 4,
"price": 25,
"status": 1,
"visibility": 1,
"type_id": "simple",
"weight": "0.5"
},
"custom_attributes": [
{
"attribute_code": "has_options",
"value": 1
},
{
"attribute_code": "required_options",
"value": 1
}
],
"options": [
{
"product_sku": "test_simple_product3",
"title": "Add Your Name (Max 15 Characters)",
"type": "field",
"sort_order": 1,
"is_require": false,
"price": 10,
"price_type": "fixed",
"sku": "Personalized",
"max_characters": 15
}
]
}
Solution
Try this payload instead:
{
"product":{
"sku":"test_simple_product3",
"name":"Test Simple Product",
"attribute_set_id":4,
"price":25,
"status":1,
"visibility":1,
"type_id":"simple",
"weight":"0.5",
"custom_attributes":[
{
"attribute_code":"has_options",
"value":1
},
{
"attribute_code":"required_options",
"value":1
}
],
"options":[
{
"product_sku":"test_simple_product3",
"title":"Add Your Name (Max 15 Characters)",
"type":"field",
"sort_order":1,
"is_require":false,
"price":10,
"price_type":"fixed",
"sku":"Personalized",
"max_characters":15
}
]
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange