Skip to content

Commit 4d9fab4

Browse files
committed
MAGETWO-90021: [Catalog] ProductAttributeMediaGalleryManagementInterface removes product from index, impossible to restore
- Make Gallery management to get product in editable mode. Fix test.
1 parent 8e2b6f9 commit 4d9fab4

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function create($sku, ProductAttributeMediaGalleryEntryInterface $entry)
5454
if (!$this->contentValidator->isValid($entryContent)) {
5555
throw new InputException(__('The image content is invalid. Verify the content and try again.'));
5656
}
57-
$product = $this->productRepository->get($sku);
57+
$product = $this->productRepository->get($sku, true);
5858

5959
$existingMediaGalleryEntries = $product->getMediaGalleryEntries();
6060
$existingEntryIds = [];
@@ -88,7 +88,7 @@ public function create($sku, ProductAttributeMediaGalleryEntryInterface $entry)
8888
*/
8989
public function update($sku, ProductAttributeMediaGalleryEntryInterface $entry)
9090
{
91-
$product = $this->productRepository->get($sku);
91+
$product = $this->productRepository->get($sku, true);
9292
$existingMediaGalleryEntries = $product->getMediaGalleryEntries();
9393
if ($existingMediaGalleryEntries == null) {
9494
throw new NoSuchEntityException(
@@ -129,7 +129,7 @@ public function update($sku, ProductAttributeMediaGalleryEntryInterface $entry)
129129
*/
130130
public function remove($sku, $entryId)
131131
{
132-
$product = $this->productRepository->get($sku);
132+
$product = $this->productRepository->get($sku, true);
133133
$existingMediaGalleryEntries = $product->getMediaGalleryEntries();
134134
if ($existingMediaGalleryEntries == null) {
135135
throw new NoSuchEntityException(

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductViewTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ public function testQueryAllFieldsSimpleProduct()
285285
*/
286286
public function testQueryMediaGalleryEntryFieldsSimpleProduct()
287287
{
288-
$this->markTestSkipped("Skipped until ticket MAGETWO-90021 is resolved.");
289288
$productSku = 'simple';
290289

291290
$query = <<<QUERY
@@ -453,7 +452,9 @@ public function testQueryMediaGalleryEntryFieldsSimpleProduct()
453452
}
454453
short_description
455454
sku
456-
small_image
455+
small_image {
456+
path
457+
}
457458
small_image_label
458459
special_from_date
459460
special_price

0 commit comments

Comments
 (0)