Skip to content

Commit

Permalink
PUT /V1/products/:sku/media/:entryId does not change the file - backport
Browse files Browse the repository at this point in the history
  • Loading branch information
niravkrish committed Apr 29, 2019
1 parent 4992141 commit 2995636
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ public function create($sku, ProductAttributeMediaGalleryEntryInterface $entry)
$product->setMediaGalleryEntries($existingMediaGalleryEntries);
try {
$product = $this->productRepository->save($product);
// phpcs:ignore Magento2.Exceptions.ThrowCatch
} catch (InputException $inputException) {
throw $inputException;
// phpcs:ignore Magento2.Exceptions.ThrowCatch
} catch (\Exception $e) {
throw new StateException(__('Cannot save product.'));
}
Expand Down Expand Up @@ -100,7 +102,10 @@ public function update($sku, ProductAttributeMediaGalleryEntryInterface $entry)

if ($existingEntry->getId() == $entry->getId()) {
$found = true;
if ($entry->getFile()) {

$file = $entry->getContent();

if ($file && $file->getBase64EncodedData() || $entry->getFile()) {
$entry->setId(null);
}
$existingMediaGalleryEntries[$key] = $entry;
Expand Down

0 comments on commit 2995636

Please sign in to comment.