Skip to content

Commit 2995636

Browse files
author
niravkrish
committed
PUT /V1/products/:sku/media/:entryId does not change the file - backport
1 parent 4992141 commit 2995636

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
@@ -68,8 +68,10 @@ public function create($sku, ProductAttributeMediaGalleryEntryInterface $entry)
6868
$product->setMediaGalleryEntries($existingMediaGalleryEntries);
6969
try {
7070
$product = $this->productRepository->save($product);
71+
// phpcs:ignore Magento2.Exceptions.ThrowCatch
7172
} catch (InputException $inputException) {
7273
throw $inputException;
74+
// phpcs:ignore Magento2.Exceptions.ThrowCatch
7375
} catch (\Exception $e) {
7476
throw new StateException(__('Cannot save product.'));
7577
}
@@ -100,7 +102,10 @@ public function update($sku, ProductAttributeMediaGalleryEntryInterface $entry)
100102

101103
if ($existingEntry->getId() == $entry->getId()) {
102104
$found = true;
103-
if ($entry->getFile()) {
105+
106+
$file = $entry->getContent();
107+
108+
if ($file && $file->getBase64EncodedData() || $entry->getFile()) {
104109
$entry->setId(null);
105110
}
106111
$existingMediaGalleryEntries[$key] = $entry;

0 commit comments

Comments
 (0)