-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Magento 2 REST API - Updating a single category also updates other attributes to not use the default value #39498
Comments
Hi @JoryHogeveen. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
Hi @engcom-Bravo. Thank you for working on this issue.
|
In Magento 2, when you use the REST API to update a category, sometimes updating a single attribute causes other attributes to be overwritten or marked as non-default. This behavior can be frustrating if you're only trying to update one attribute. Here’s an explanation of why this happens and how to avoid it: Why does this happen? Example: json How to Update Only a Single Attribute: Default Values Handling: If you only need to modify a single attribute (e.g., the name), make sure to include all other attributes in your request with their current values. This way, the values you don't want to change will not be overwritten. Step-by-step approach: First, retrieve the current category data using the GET request to the /V1/categories/{categoryId} endpoint. GET request to retrieve category data: bash json json Using Magento's GraphQL as an Alternative: For instance, updating a category using GraphQL: graphql |
Preconditions and environment
I've already posted this on StackExchange:
https://magento.stackexchange.com/questions/375887/magento-2-rest-api-updating-a-single-category-also-updates-other-attributes-to
Due to the nature of this issue I really think it's a bug. And if not, an documentation issue.
Steps to reproduce
Expected result
The API should only update the data you send to it.
Actual result
The API updates a lot of other attributes like name, visibility etc.
Even though this will update that particular attribute just fine, it will also set several other attributes to overwrite the default value.
See example return under additional information. All attributes seen in the response below are not set to default anymore. Note that many other attributes, also store-view attributes among them like "page_layout", are still set to default...
I have no explanation as to why some attributes are switched to not use the default anymore and some others are not. Hope someone can help me with this as I am totally lost after hours of testing.
Additional information
API request:
POST: /store_view_code/V1/products/
API response:
Release note
I've set this to severity S0 as with the current state it will override important attributes like visibility, status and name without intent. This can create big issues on live instances where users could suddenly see hidden products in the catalog or even products with incorrect data.
Triage and priority
The text was updated successfully, but these errors were encountered: