From bb5ae76a3ec64ba47123685b5a514222caf10c68 Mon Sep 17 00:00:00 2001 From: Ievgenii Gryshkun Date: Mon, 20 May 2019 10:09:35 +0300 Subject: [PATCH 1/3] 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/3] 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 From 44d7ff4815bbcb87e3acd5a8c59b90318c3b2089 Mon Sep 17 00:00:00 2001 From: Lena Orobei Date: Wed, 12 Jun 2019 11:43:38 -0500 Subject: [PATCH 3/3] magento/graphql-ce#612: Product media_gallery_entries / types only present if image, thumbnail, small_image is requested - skipped test magento/graphql-ce#738 --- .../Model/Resolver/Products/DataProvider/Product.php | 2 +- .../testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) 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 3cd881da8fbc4..7f1fd71942253 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) { 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 38ba4760e93a3..49e2a9dd53999 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php @@ -9,6 +9,9 @@ use Magento\TestFramework\TestCase\GraphQlAbstract; +/** + * Test cases for product media gallery data retrieval. + */ class MediaGalleryTest extends GraphQlAbstract { /** @@ -50,6 +53,7 @@ public function testProductSmallImageUrlWithExistingImage() */ public function testProductMediaGalleryEntries() { + $this->markTestSkipped('https://github.com/magento/graphql-ce/issues/738'); $productSku = 'simple'; $query = <<