Skip to content

Commit cd4adc3

Browse files
authored
ENGCOM-4786: PUT /V1/products/:sku/media/:entryId does not change the file #22424
2 parents 962ef05 + 71c500d commit cd4adc3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ public function create($sku, ProductAttributeMediaGalleryEntryInterface $entry)
7171
$product->setMediaGalleryEntries($existingMediaGalleryEntries);
7272
try {
7373
$product = $this->productRepository->save($product);
74+
// phpcs:ignore Magento2.Exceptions.ThrowCatch
7475
} catch (InputException $inputException) {
7576
throw $inputException;
77+
// phpcs:ignore Magento2.Exceptions.ThrowCatch
7678
} catch (\Exception $e) {
7779
throw new StateException(__("The product can't be saved."));
7880
}
@@ -105,7 +107,10 @@ public function update($sku, ProductAttributeMediaGalleryEntryInterface $entry)
105107

106108
if ($existingEntry->getId() == $entry->getId()) {
107109
$found = true;
108-
if ($entry->getFile()) {
110+
111+
$file = $entry->getContent();
112+
113+
if ($file && $file->getBase64EncodedData() || $entry->getFile()) {
109114
$entry->setId(null);
110115
}
111116
$existingMediaGalleryEntries[$key] = $entry;

0 commit comments

Comments
 (0)