Skip to content

Commit b891e81

Browse files
committed
Merge remote-tracking branch 'origin/MC-23733' into 2.4-develop-pr21
2 parents bb70ad5 + c6958ca commit b891e81

File tree

3 files changed

+46
-74
lines changed

3 files changed

+46
-74
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Image/Placeholder.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
namespace Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Image;
99

1010
use Magento\Catalog\Model\View\Asset\PlaceholderFactory;
11+
use Magento\Framework\App\Area;
1112
use Magento\Framework\View\Asset\Repository as AssetRepository;
13+
use Magento\Framework\View\DesignInterface;
1214

1315
/**
1416
* Image Placeholder provider
@@ -25,16 +27,24 @@ class Placeholder
2527
*/
2628
private $assetRepository;
2729

30+
/**
31+
* @var DesignInterface
32+
*/
33+
private $themeDesign;
34+
2835
/**
2936
* @param PlaceholderFactory $placeholderFactory
3037
* @param AssetRepository $assetRepository
38+
* @param DesignInterface $themeDesign
3139
*/
3240
public function __construct(
3341
PlaceholderFactory $placeholderFactory,
34-
AssetRepository $assetRepository
42+
AssetRepository $assetRepository,
43+
DesignInterface $themeDesign
3544
) {
3645
$this->placeholderFactory = $placeholderFactory;
3746
$this->assetRepository = $assetRepository;
47+
$this->themeDesign = $themeDesign;
3848
}
3949

4050
/**
@@ -52,8 +62,14 @@ public function getPlaceholder(string $imageType): string
5262
return $imageAsset->getUrl();
5363
}
5464

55-
return $this->assetRepository->getUrl(
56-
"Magento_Catalog::images/product/placeholder/{$imageType}.jpg"
65+
$params = [
66+
'area' => Area::AREA_FRONTEND,
67+
'themeId' => $this->themeDesign->getConfigurationDesignTheme(Area::AREA_FRONTEND),
68+
];
69+
70+
return $this->assetRepository->getUrlWithParams(
71+
"Magento_Catalog::images/product/placeholder/{$imageType}.jpg",
72+
$params
5773
);
5874
}
5975
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Image/Placeholder/Theme.php

Lines changed: 0 additions & 71 deletions
This file was deleted.

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,33 @@ public function testProductSmallImageUrlWithExistingImage()
3838
self::assertTrue($this->checkImageExists($response['products']['items'][0]['small_image']['url']));
3939
}
4040

41+
/**
42+
* Test for get product image placeholder
43+
*
44+
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
45+
*/
46+
public function testProductSmallImageUrlPlaceholder()
47+
{
48+
$productSku = 'simple';
49+
$query = <<<QUERY
50+
{
51+
products(filter: {sku: {eq: "{$productSku}"}}) {
52+
items {
53+
small_image {
54+
url
55+
}
56+
}
57+
}
58+
}
59+
QUERY;
60+
$response = $this->graphQlQuery($query);
61+
$responseImage = $response['products']['items'][0]['small_image'];
62+
63+
self::assertArrayHasKey('url', $responseImage);
64+
self::assertContains('placeholder/small_image.jpg', $responseImage['url']);
65+
self::assertTrue($this->checkImageExists($responseImage['url']));
66+
}
67+
4168
/**
4269
* @magentoApiDataFixture Magento/Catalog/_files/product_with_multiple_images.php
4370
*/

0 commit comments

Comments
 (0)