-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Steps to reproduce
- Create a new configurable product
- Use the REST API to add a new option to the new product (this works):
URL: http://[base url]/rest/V1/configurable-products/basecap/options
POST BODY:
{
"option" :
{
"attribute_id": "font_type",
"label": "font type",
"position": 0,
"values": [
{
"value_index": 216
}
]
}
} - Use the REST API to add a second option to the new product:
URL: http://[base url]/rest/V1/configurable-products/basecap/options
POST BODY:
{
"option" :
{
"attribute_id": "font_color",
"label": "font color",
"position": 1,
"values": [
{
"value_index": 213
},
{
"value_index": 214
}
]
}
}
The second option returns error "Something went wrong while saving option."
Expected result
- Additional option added to configurable product and a 200 response from REST API.
Actual result
{
"message": "Something went wrong while saving option.",
"trace": "#0 [internal function]: Magento\ConfigurableProduct\Model\OptionRepository->save('basecap', Object(Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute))\n#1 /var/www/magento2-dev/vendor/magento/module-webapi/Controller/Rest.php(265): call_user_func_array(Array, Array)\n#2 /var/www/magento2-dev/vendor/magento/module-webapi/Controller/Rest.php(160): Magento\Webapi\Controller\Rest->processApiRequest()\n#3 /var/www/magento2-dev/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(24): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))\n#4 /var/www/magento2-dev/vendor/magento/framework/App/Http.php(115): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#5 /var/www/magento2-dev/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()\n#6 /var/www/magento2-dev/pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))\n#7 {main}"
}
Additional observation: when enabling mysql general logging, I see that something deletes the attribute immediately after creating it:
(mysql log entry): DELETE FROM catalog_product_super_attribute WHERE (product_super_attribute_id='426')
This occurs immediately before the code checks to verify that the attribute created successfully on line 238 of vendor/magento/module-configurable-product/Model/OptionRepository.php in v2.0.7:
if (!$configurableAttribute->getId()) {
throw new CouldNotSaveException(__('Something went wrong while saving option.'));
}
This issue occurs in both 2.0.7 and 2.1.