From 9205c6fa88e3de4ac09e48a85cd193507d47e1f7 Mon Sep 17 00:00:00 2001 From: Nazarn96 Date: Fri, 19 Apr 2019 12:19:00 +0300 Subject: [PATCH 1/2] PUT /V1/products/:sku/media/:entryId does not change the file --- .../Catalog/Model/Product/Gallery/GalleryManagement.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php b/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php index 0e08b0af92862..9e5cf084c25a1 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php +++ b/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php @@ -105,7 +105,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; From 24580ee3eb4c87cca94d73b9e377621750708234 Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky Date: Mon, 22 Apr 2019 16:00:04 +0300 Subject: [PATCH 2/2] magento/magento2#22424: Static test fix. --- .../Magento/Catalog/Model/Product/Gallery/GalleryManagement.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php b/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php index 9e5cf084c25a1..c993e51c8bc09 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php +++ b/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php @@ -71,8 +71,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(__("The product can't be saved.")); }