Skip to content

Unable to save certain product properties via Rest API #6486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cherreman opened this issue Sep 5, 2016 · 6 comments
Closed

Unable to save certain product properties via Rest API #6486

cherreman opened this issue Sep 5, 2016 · 6 comments
Assignees
Labels
bug report Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Component: Tax Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@cherreman
Copy link

Preconditions

  1. Magento 2.1.1

Steps to reproduce

  1. Create a product via the Rest API, including a price and weight

Expected result

  1. The product is saved with the price and weight

Actual result

  1. The price and weight are not saved and are not returned in the result of the POST request.

I traced this down to the BeforeEntitySave observer, where the price seems to be stripped off the product when $entity->beforeSave() is called. I did not continue research after that.

Workaround is to execute the post request again. During the update of the product, the price seems the be saved correctly.

@andimov andimov added Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Component: Tax 2.1.x bug report labels Sep 5, 2016
@sevos1984
Copy link
Contributor

Could you please attach payload of your request?

@sevos1984 sevos1984 self-assigned this Sep 6, 2016
@cherreman
Copy link
Author

Request

{
"product": {
"sku": "bugtest",
"name": "bugtest",
"price": 12.34,
"attribute_set_id": 4
}
}

Response

{
"id": 5991,
"sku": "bugtest",
"name": "bugtest",
"attribute_set_id": 4,
"status": 1,
"visibility": 4,
"type_id": "simple",
"created_at": "2016-09-06 13:46:56",
"updated_at": "2016-09-06 13:46:56",
"extension_attributes": {
"stock_item": {
"item_id": 5957,
"product_id": 5991,
"stock_id": 1,
"qty": null,
"is_in_stock": true,
"is_qty_decimal": false,
"show_default_notification_message": false,
"use_config_min_qty": true,
"min_qty": 0,
"use_config_min_sale_qty": 1,
"min_sale_qty": 1,
"use_config_max_sale_qty": true,
"max_sale_qty": 10000,
"use_config_backorders": true,
"backorders": 0,
"use_config_notify_stock_qty": true,
"notify_stock_qty": 1,
"use_config_qty_increments": true,
"qty_increments": 0,
"use_config_enable_qty_inc": true,
"enable_qty_increments": false,
"use_config_manage_stock": true,
"manage_stock": false,
"low_stock_date": null,
"is_decimal_divided": false,
"stock_status_changed_auto": 0
}
},
"product_links": [],
"options": [],
"media_gallery_entries": [],
"tier_prices": [],
"custom_attributes": [
{
"attribute_code": "category_ids",
"value": []
},
{
"attribute_code": "options_container",
"value": "container2"
},
{
"attribute_code": "required_options",
"value": "0"
},
{
"attribute_code": "has_options",
"value": "0"
},
{
"attribute_code": "url_key",
"value": "bugtest"
}
]
}

Response from second identical post

{
"id": 5991,
"sku": "bugtest",
"name": "bugtest",
"attribute_set_id": 4,
"price": 12.34,
"status": 1,
"visibility": 4,
"type_id": "simple",
"created_at": "2016-09-06 13:46:56",
"updated_at": "2016-09-06 13:46:56",
"extension_attributes": {
"stock_item": {
"item_id": 5957,
"product_id": 5991,
"stock_id": 1,
"qty": null,
"is_in_stock": true,
"is_qty_decimal": false,
"show_default_notification_message": false,
"use_config_min_qty": true,
"min_qty": 0,
"use_config_min_sale_qty": 1,
"min_sale_qty": 1,
"use_config_max_sale_qty": true,
"max_sale_qty": 10000,
"use_config_backorders": true,
"backorders": 0,
"use_config_notify_stock_qty": true,
"notify_stock_qty": 1,
"use_config_qty_increments": true,
"qty_increments": 0,
"use_config_enable_qty_inc": true,
"enable_qty_increments": false,
"use_config_manage_stock": true,
"manage_stock": false,
"low_stock_date": "2016-09-06 13:48:37",
"is_decimal_divided": false,
"stock_status_changed_auto": 0
}
},
"product_links": [],
"options": [],
"media_gallery_entries": [],
"tier_prices": [],
"custom_attributes": [
{
"attribute_code": "category_ids",
"value": []
},
{
"attribute_code": "options_container",
"value": "container2"
},
{
"attribute_code": "required_options",
"value": "0"
},
{
"attribute_code": "has_options",
"value": "0"
},
{
"attribute_code": "url_key",
"value": "bugtest"
},
{
"attribute_code": "tax_class_id",
"value": "2"
}
]
}

@sevos1984
Copy link
Contributor

This happens when product type_id field is not defined. Created internal ticket MAGETWO-58101. Thanks for reporting.

@sevos1984 sevos1984 added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development and removed Progress: needs update labels Sep 6, 2016
@sevos1984 sevos1984 removed their assignment Sep 7, 2016
@cherreman
Copy link
Author

Thanks for the heads up!

@magento-engcom-team magento-engcom-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Component: Tax Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog labels Sep 11, 2017
@magento-engcom-team
Copy link
Contributor

@cherreman, thank you for your report.
We've created internal ticket(s) MAGETWO-58101 to track progress on the issue.

@magento-engcom-team magento-engcom-team added 2.2.x Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Oct 11, 2017
@nmalevanec nmalevanec self-assigned this Dec 13, 2017
@magento-team
Copy link
Contributor

Hi @cherreman. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1018 by @nmalevanec in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming patch release.

@magento-team magento-team added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Jan 11, 2018
magento-engcom-team pushed a commit that referenced this issue Dec 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Component: Tax Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

6 participants