Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/code/Magento/Catalog/Model/CategoryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

unset($existingData['name']);
}

if ($category->getId()) {
$metadata = $this->getMetadataPool()->getMetadata(
CategoryInterface::class
Expand Down