-
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
Patch #22309: Remove "null" value of not passed name attribute #22310
Conversation
If a category is updated via REST API in the "all" scope and the category name is not sent, Magento use "null" as value for the name, This leads into a validation error, because the category name is required. In this case we remove the null value out of the automatically generated default value array. Magento will then skip the category, because there is no change.
Hi @cmuench. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
@cmuench unfortunately, only members of the maintainers team are allowed to assign developers to the pull request |
@@ -80,6 +80,10 @@ public function save(\Magento\Catalog\Api\Data\CategoryInterface $category) | |||
$existingData = array_diff_key($existingData, array_flip(['path', 'level', 'parent_id'])); | |||
$existingData['store_id'] = $storeId; | |||
|
|||
if (array_key_exists('name', $existingData) && $existingData['name'] === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of unsetting, please fix a place where name is set to null
.
Are you sure such request in issue is valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The request is valid.
See screenshot in issue. This is a real world example. One of our customers wan't to change the the "is_active" flag. It is not possible to change the global value without to specify the name. If you send the same call with a store code it is OK.
Partial updates are supported by Magento.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@orlangur I am also not satisfied by this solution but the problem is in the framework.
The "null" value is generated by this method: \Magento\Framework\Reflection\DataObjectProcessor::buildOutputDataArray
.
Do you have any good idea to handle that?
Fixed by PR #22362 |
Hi @cmuench, thank you for your contribution! |
Description
If a category is updated via REST API in the "all" scope and the
category name is not sent, Magento use "null" as value for the name,
This leads into a validation error, because the category name is
required.
In this case we remove the null value out of the automatically
generated default value array. Magento will then skip the category,
because there is no change.
Fixed Issues
Manual testing scenarios
Contribution checklist