From bb5ae76a3ec64ba47123685b5a514222caf10c68 Mon Sep 17 00:00:00 2001 From: Ievgenii Gryshkun Date: Mon, 20 May 2019 10:09:35 +0300 Subject: [PATCH 1/2] Product media_gallery_entries / types only present if image, thumbnail, small_image is requested --- .../Model/Resolver/Products/DataProvider/Product.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product.php index 7f1fd71942253..3cd881da8fbc4 100644 --- a/app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product.php +++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product.php @@ -74,7 +74,7 @@ public function getList( ): SearchResultsInterface { /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */ $collection = $this->collectionFactory->create(); - + $attributes = array_unique(array_merge($attributes, ['small_image', 'thumbnail', 'image'])); $this->collectionProcessor->process($collection, $searchCriteria, $attributes); if (!$isChildSearch) { From b776ec3a61e4f0d84c2b8abf74a8f789ee9724cd Mon Sep 17 00:00:00 2001 From: Ievgenii Gryshkun Date: Tue, 11 Jun 2019 11:15:29 +0300 Subject: [PATCH 2/2] Product media_gallery_entries / types only present if image, thumbnail, small_image is requested --- .../GraphQl/Catalog/MediaGalleryTest.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php index 8da2702917af0..38ba4760e93a3 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php @@ -45,6 +45,33 @@ public function testProductSmallImageUrlWithExistingImage() self::assertTrue($this->checkImageExists($response['products']['items'][0]['small_image']['url'])); } + /** + * @magentoApiDataFixture Magento/Catalog/_files/product_with_image.php + */ + public function testProductMediaGalleryEntries() + { + $productSku = 'simple'; + $query = <<graphQlQuery($query); + + self::assertArrayHasKey('file', $response['products']['items'][0]['media_gallery_entries'][0]); + self::assertContains('magento_image.jpg', $response['products']['items'][0]['media_gallery_entries'][0]['url']); + } + /** * @param string $url * @return bool