Skip to content

Commit 4539b52

Browse files
committed
Merge remote-tracking branch 'origin/2.3-develop' into mtf-eol
2 parents 27b4abe + 16036cd commit 4539b52

File tree

72 files changed

+1064
-243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1064
-243
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/GridOnly.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Catalog\Controller\Adminhtml\Product;
87

9-
class GridOnly extends \Magento\Catalog\Controller\Adminhtml\Product
8+
use Magento\Framework\App\Action\HttpGetActionInterface;
9+
10+
/**
11+
* Get specified tab grid controller.
12+
*/
13+
class GridOnly extends \Magento\Catalog\Controller\Adminhtml\Product implements HttpGetActionInterface
1014
{
1115
/**
1216
* @var \Magento\Framework\Controller\Result\RawFactory
@@ -47,7 +51,7 @@ public function execute()
4751
$this->productBuilder->build($this->getRequest());
4852

4953
$block = $this->getRequest()->getParam('gridOnlyBlock');
50-
$blockClassSuffix = str_replace(' ', '_', ucwords(str_replace('_', ' ', $block)));
54+
$blockClassSuffix = ucwords($block, '_');
5155

5256
/** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
5357
$resultRaw = $this->resultRawFactory->create();

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeGridSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="AdminProductAttributeGridSection">
1212
<element name="AttributeCode" type="text" selector="//td[contains(text(),'{{var1}}')]" parameterized="true" timeout="30"/>
13-
<element name="createNewAttributeBtn" type="button" selector="button[data-index='add_new_attribute_button']"/>
13+
<element name="createNewAttributeBtn" type="button" selector="#add"/>
1414
<element name="GridFilterFrontEndLabel" type="input" selector="#attributeGrid_filter_frontend_label"/>
1515
<element name="Search" type="button" selector="button[data-action=grid-filter-apply]" timeout="30"/>
1616
<element name="ResetFilter" type="button" selector="button[data-action='grid-filter-reset']" timeout="30"/>

app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCustomProductAttributeWithDropdownFieldTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<!-- Create New Product Attribute -->
6060
<click selector="{{AdminProductFormSection.addAttributeBtn}}" stepKey="clickOnAddAttribute"/>
6161
<waitForPageLoad stepKey="waitForAttributePageToLoad"/>
62-
<click selector="{{AdminProductAttributeGridSection.createNewAttributeBtn}}" stepKey="clickCreateNewAttributeButton"/>
62+
<click selector="{{AdminProductFormSection.createNewAttributeBtn}}" stepKey="clickCreateNewAttributeButton"/>
6363
<waitForPageLoad stepKey="waitForNewAttributePageToLoad"/>
6464
<waitForElementVisible selector="{{AdminCreateNewProductAttributeSection.defaultLabel}}" stepKey="waitForDefaultLabelToBeVisible"/>
6565
<fillField selector="{{AdminCreateNewProductAttributeSection.defaultLabel}}" userInput="{{ProductAttributeFrontendLabel.label}}" stepKey="fillAttributeLabel"/>

app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductAttributeFromProductPageTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<!-- Create New Product Attribute -->
6060
<click selector="{{AdminProductFormSection.addAttributeBtn}}" stepKey="clickOnAddAttribute"/>
6161
<waitForPageLoad stepKey="waitForAttributePageToLoad"/>
62-
<click selector="{{AdminProductAttributeGridSection.createNewAttributeBtn}}" stepKey="clickCreateNewAttributeButton"/>
62+
<click selector="{{AdminProductFormSection.createNewAttributeBtn}}" stepKey="clickCreateNewAttributeButton"/>
6363
<waitForPageLoad stepKey="waitForNewAttributePageToLoad"/>
6464
<waitForElementVisible selector="{{AdminCreateNewProductAttributeSection.defaultLabel}}" stepKey="waitForDefaultLabelToBeVisible"/>
6565
<fillField selector="{{AdminCreateNewProductAttributeSection.defaultLabel}}" userInput="{{ProductAttributeFrontendLabel.label}}" stepKey="fillAttributeLabel"/>

app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductAttributeRequiredTextFieldTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<!-- Create Product Attribute -->
5858
<click selector="{{AdminProductFormSection.addAttributeBtn}}" stepKey="clickOnAddAttribute"/>
5959
<waitForPageLoad stepKey="waitForAttributePageToLoad"/>
60-
<click selector="{{AdminProductAttributeGridSection.createNewAttributeBtn}}" stepKey="clickCreateNewAttributeButton"/>
60+
<click selector="{{AdminProductFormSection.createNewAttributeBtn}}" stepKey="clickCreateNewAttributeButton"/>
6161
<waitForPageLoad stepKey="waitForNewAttributePageToLoad"/>
6262
<waitForElementVisible selector="{{AdminCreateNewProductAttributeSection.defaultLabel}}" stepKey="waitForDefaultLabelToBeVisible"/>
6363
<fillField selector="{{AdminCreateNewProductAttributeSection.defaultLabel}}" userInput="{{ProductAttributeFrontendLabel.label}}" stepKey="fillAttributeLabel"/>

app/code/Magento/CatalogGraphQl/Model/Resolver/Product/ProductImage/Url.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Catalog\Model\Product;
1111
use Magento\Catalog\Model\Product\ImageFactory;
12+
use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Image\Placeholder as PlaceholderProvider;
1213
use Magento\Framework\Exception\LocalizedException;
1314
use Magento\Framework\GraphQl\Config\Element\Field;
1415
use Magento\Framework\GraphQl\Query\ResolverInterface;
@@ -23,14 +24,21 @@ class Url implements ResolverInterface
2324
* @var ImageFactory
2425
*/
2526
private $productImageFactory;
27+
/**
28+
* @var PlaceholderProvider
29+
*/
30+
private $placeholderProvider;
2631

2732
/**
2833
* @param ImageFactory $productImageFactory
34+
* @param PlaceholderProvider $placeholderProvider
2935
*/
3036
public function __construct(
31-
ImageFactory $productImageFactory
37+
ImageFactory $productImageFactory,
38+
PlaceholderProvider $placeholderProvider
3239
) {
3340
$this->productImageFactory = $productImageFactory;
41+
$this->placeholderProvider = $placeholderProvider;
3442
}
3543

3644
/**
@@ -55,23 +63,27 @@ public function resolve(
5563
$product = $value['model'];
5664
$imagePath = $product->getData($value['image_type']);
5765

58-
$imageUrl = $this->getImageUrl($value['image_type'], $imagePath);
59-
return $imageUrl;
66+
return $this->getImageUrl($value['image_type'], $imagePath);
6067
}
6168

6269
/**
63-
* Get image url
70+
* Get image URL
6471
*
6572
* @param string $imageType
66-
* @param string|null $imagePath Null if image is not set
73+
* @param string|null $imagePath
6774
* @return string
75+
* @throws \Exception
6876
*/
6977
private function getImageUrl(string $imageType, ?string $imagePath): string
7078
{
7179
$image = $this->productImageFactory->create();
7280
$image->setDestinationSubdir($imageType)
7381
->setBaseFile($imagePath);
74-
$imageUrl = $image->getUrl();
75-
return $imageUrl;
82+
83+
if ($image->isBaseFilePlaceholder()) {
84+
return $this->placeholderProvider->getPlaceholder($imageType);
85+
}
86+
87+
return $image->getUrl();
7688
}
7789
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Image;
9+
10+
use Magento\Catalog\Model\View\Asset\PlaceholderFactory;
11+
use Magento\Framework\View\Asset\Repository as AssetRepository;
12+
13+
/**
14+
* Image Placeholder provider
15+
*/
16+
class Placeholder
17+
{
18+
/**
19+
* @var PlaceholderFactory
20+
*/
21+
private $placeholderFactory;
22+
23+
/**
24+
* @var AssetRepository
25+
*/
26+
private $assetRepository;
27+
28+
/**
29+
* @param PlaceholderFactory $placeholderFactory
30+
* @param AssetRepository $assetRepository
31+
*/
32+
public function __construct(
33+
PlaceholderFactory $placeholderFactory,
34+
AssetRepository $assetRepository
35+
) {
36+
$this->placeholderFactory = $placeholderFactory;
37+
$this->assetRepository = $assetRepository;
38+
}
39+
40+
/**
41+
* Get placeholder
42+
*
43+
* @param string $imageType
44+
* @return string
45+
*/
46+
public function getPlaceholder(string $imageType): string
47+
{
48+
$imageAsset = $this->placeholderFactory->create(['type' => $imageType]);
49+
50+
// check if placeholder defined in config
51+
if ($imageAsset->getFilePath()) {
52+
return $imageAsset->getUrl();
53+
}
54+
55+
return $this->assetRepository->getUrl(
56+
"Magento_Catalog::images/product/placeholder/{$imageType}.jpg"
57+
);
58+
}
59+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Image\Placeholder;
9+
10+
use Magento\Framework\App\Config\ScopeConfigInterface;
11+
use Magento\Framework\View\Design\Theme\ThemeProviderInterface;
12+
use Magento\Store\Model\StoreManagerInterface;
13+
14+
/**
15+
* Theme provider
16+
*/
17+
class Theme
18+
{
19+
/**
20+
* @var ScopeConfigInterface
21+
*/
22+
private $scopeConfig;
23+
24+
/**
25+
* @var StoreManagerInterface
26+
*/
27+
private $storeManager;
28+
29+
/**
30+
* @var ThemeProviderInterface
31+
*/
32+
private $themeProvider;
33+
34+
/**
35+
* @param ScopeConfigInterface $scopeConfig
36+
* @param StoreManagerInterface $storeManager
37+
* @param ThemeProviderInterface $themeProvider
38+
*/
39+
public function __construct(
40+
ScopeConfigInterface $scopeConfig,
41+
StoreManagerInterface $storeManager,
42+
ThemeProviderInterface $themeProvider
43+
) {
44+
$this->scopeConfig = $scopeConfig;
45+
$this->storeManager = $storeManager;
46+
$this->themeProvider = $themeProvider;
47+
}
48+
49+
/**
50+
* Get theme model
51+
*
52+
* @return array
53+
* @throws \Magento\Framework\Exception\NoSuchEntityException
54+
*/
55+
public function getThemeData(): array
56+
{
57+
$themeId = $this->scopeConfig->getValue(
58+
\Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID,
59+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
60+
$this->storeManager->getStore()->getId()
61+
);
62+
63+
/** @var $theme \Magento\Framework\View\Design\ThemeInterface */
64+
$theme = $this->themeProvider->getThemeById($themeId);
65+
66+
$data = $theme->getData();
67+
$data['themeModel'] = $theme;
68+
69+
return $data;
70+
}
71+
}

app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CurrentUrlRewritesRegeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ protected function getCurrentRewritesMocks($currentRewrites)
252252
->disableOriginalConstructor()->getMock();
253253
foreach ($urlRewrite as $key => $value) {
254254
$url->expects($this->any())
255-
->method('get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))))
255+
->method('get' . str_replace('_', '', ucwords($key, '_')))
256256
->will($this->returnValue($value));
257257
}
258258
$rewrites[] = $url;

app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CurrentUrlRewritesRegeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ protected function getCurrentRewritesMocks($currentRewrites)
294294
->disableOriginalConstructor()->getMock();
295295
foreach ($urlRewrite as $key => $value) {
296296
$url->expects($this->any())
297-
->method('get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))))
297+
->method('get' . str_replace('_', '', ucwords($key, '_')))
298298
->will($this->returnValue($value));
299299
}
300300
$rewrites[] = $url;

0 commit comments

Comments
 (0)