Skip to content

Commit 39f9fed

Browse files
committed
Merge remote-tracking branch 'origin/2.3-develop' into MC-23211
2 parents f93b8c5 + 84c71b5 commit 39f9fed

File tree

249 files changed

+8731
-1123
lines changed

Some content is hidden

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

249 files changed

+8731
-1123
lines changed

app/code/Magento/Backend/Block/Media/Uploader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected function _construct()
8787

8888
$this->setId($this->getId() . '_Uploader');
8989

90-
$uploadUrl = $this->_urlBuilder->addSessionParam()->getUrl('adminhtml/*/upload');
90+
$uploadUrl = $this->_urlBuilder->getUrl('adminhtml/*/upload');
9191
$this->getConfig()->setUrl($uploadUrl);
9292
$this->getConfig()->setParams(['form_key' => $this->getFormKey()]);
9393
$this->getConfig()->setFileField('file');

app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected function _prepareLayout()
9595
);
9696

9797
$this->getUploader()->getConfig()->setUrl(
98-
$this->_urlBuilder->addSessionParam()->getUrl('catalog/product_gallery/upload')
98+
$this->_urlBuilder->getUrl('catalog/product_gallery/upload')
9999
)->setFileField(
100100
'image'
101101
)->setFilters(

app/code/Magento/Catalog/Model/Category/Attribute/Backend/Image.php

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
*/
66
namespace Magento\Catalog\Model\Category\Attribute\Backend;
77

8+
use Magento\Catalog\Model\ImageUploader;
89
use Magento\Framework\App\Filesystem\DirectoryList;
10+
use Magento\Framework\App\ObjectManager;
911
use Magento\Framework\File\Uploader;
12+
use Magento\Store\Api\Data\StoreInterface;
13+
use Magento\Store\Model\StoreManagerInterface;
1014

1115
/**
1216
* Catalog category image attribute backend model
@@ -45,7 +49,7 @@ class Image extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
4549
protected $_logger;
4650

4751
/**
48-
* @var \Magento\Catalog\Model\ImageUploader
52+
* @var ImageUploader
4953
*/
5054
private $imageUploader;
5155

@@ -54,19 +58,32 @@ class Image extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
5458
*/
5559
private $additionalData = '_additional_data_';
5660

61+
/**
62+
* @var StoreManagerInterface
63+
*/
64+
private $storeManager;
65+
5766
/**
5867
* @param \Psr\Log\LoggerInterface $logger
5968
* @param \Magento\Framework\Filesystem $filesystem
6069
* @param \Magento\MediaStorage\Model\File\UploaderFactory $fileUploaderFactory
70+
* @param StoreManagerInterface $storeManager
71+
* @param ImageUploader $imageUploader
6172
*/
6273
public function __construct(
6374
\Psr\Log\LoggerInterface $logger,
6475
\Magento\Framework\Filesystem $filesystem,
65-
\Magento\MediaStorage\Model\File\UploaderFactory $fileUploaderFactory
76+
\Magento\MediaStorage\Model\File\UploaderFactory $fileUploaderFactory,
77+
StoreManagerInterface $storeManager = null,
78+
ImageUploader $imageUploader = null
6679
) {
6780
$this->_filesystem = $filesystem;
6881
$this->_fileUploaderFactory = $fileUploaderFactory;
6982
$this->_logger = $logger;
83+
$this->storeManager = $storeManager ??
84+
ObjectManager::getInstance()->get(StoreManagerInterface::class);
85+
$this->imageUploader = $imageUploader ??
86+
ObjectManager::getInstance()->get(ImageUploader::class);
7087
}
7188

7289
/**
@@ -91,16 +108,17 @@ private function getUploadedImageName($value)
91108
*
92109
* @param string $imageName
93110
* @return string
111+
* @throws \Magento\Framework\Exception\FileSystemException
94112
*/
95113
private function checkUniqueImageName(string $imageName): string
96114
{
97-
$imageUploader = $this->getImageUploader();
98115
$mediaDirectory = $this->_filesystem->getDirectoryWrite(DirectoryList::MEDIA);
99116
$imageAbsolutePath = $mediaDirectory->getAbsolutePath(
100-
$imageUploader->getBasePath() . DIRECTORY_SEPARATOR . $imageName
117+
$this->imageUploader->getBasePath() . DIRECTORY_SEPARATOR . $imageName
101118
);
102119

103-
$imageName = Uploader::getNewFilename($imageAbsolutePath);
120+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
121+
$imageName = call_user_func([Uploader::class, 'getNewFilename'], $imageAbsolutePath);
104122

105123
return $imageName;
106124
}
@@ -112,14 +130,26 @@ private function checkUniqueImageName(string $imageName): string
112130
*
113131
* @param \Magento\Framework\DataObject $object
114132
* @return $this
133+
* @throws \Magento\Framework\Exception\FileSystemException
115134
* @since 101.0.8
116135
*/
117136
public function beforeSave($object)
118137
{
119138
$attributeName = $this->getAttribute()->getName();
120139
$value = $object->getData($attributeName);
121140

122-
if ($this->fileResidesOutsideCategoryDir($value)) {
141+
if ($this->isTmpFileAvailable($value) && $imageName = $this->getUploadedImageName($value)) {
142+
try {
143+
/** @var StoreInterface $store */
144+
$store = $this->storeManager->getStore();
145+
$baseMediaDir = $store->getBaseMediaDir();
146+
$newImgRelativePath = $this->imageUploader->moveFileFromTmp($imageName, true);
147+
$value[0]['url'] = '/' . $baseMediaDir . '/' . $newImgRelativePath;
148+
$value[0]['name'] = $value[0]['url'];
149+
} catch (\Exception $e) {
150+
$this->_logger->critical($e);
151+
}
152+
} elseif ($this->fileResidesOutsideCategoryDir($value)) {
123153
// use relative path for image attribute so we know it's outside of category dir when we fetch it
124154
// phpcs:ignore Magento2.Functions.DiscouragedFunction
125155
$value[0]['url'] = parse_url($value[0]['url'], PHP_URL_PATH);
@@ -139,23 +169,6 @@ public function beforeSave($object)
139169
return parent::beforeSave($object);
140170
}
141171

142-
/**
143-
* Get Instance of Category Image Uploader.
144-
*
145-
* @return \Magento\Catalog\Model\ImageUploader
146-
*
147-
* @deprecated 101.0.0
148-
*/
149-
private function getImageUploader()
150-
{
151-
if ($this->imageUploader === null) {
152-
$this->imageUploader = \Magento\Framework\App\ObjectManager::getInstance()
153-
->get(\Magento\Catalog\CategoryImageUpload::class);
154-
}
155-
156-
return $this->imageUploader;
157-
}
158-
159172
/**
160173
* Check if temporary file is available for new image upload.
161174
*
@@ -194,19 +207,10 @@ private function fileResidesOutsideCategoryDir($value)
194207
*
195208
* @param \Magento\Framework\DataObject $object
196209
* @return \Magento\Catalog\Model\Category\Attribute\Backend\Image
210+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
197211
*/
198212
public function afterSave($object)
199213
{
200-
$value = $object->getData($this->additionalData . $this->getAttribute()->getName());
201-
202-
if ($this->isTmpFileAvailable($value) && $imageName = $this->getUploadedImageName($value)) {
203-
try {
204-
$this->getImageUploader()->moveFileFromTmp($imageName);
205-
} catch (\Exception $e) {
206-
$this->_logger->critical($e);
207-
}
208-
}
209-
210214
return $this;
211215
}
212216
}

app/code/Magento/Catalog/Model/ImageUploader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ public function getFilePath($path, $imageName)
191191
* Checking file for moving and move it
192192
*
193193
* @param string $imageName
194-
*
194+
* @param bool $returnRelativePath
195195
* @return string
196196
*
197197
* @throws \Magento\Framework\Exception\LocalizedException
198198
*/
199-
public function moveFileFromTmp($imageName)
199+
public function moveFileFromTmp($imageName, $returnRelativePath = false)
200200
{
201201
$baseTmpPath = $this->getBaseTmpPath();
202202
$basePath = $this->getBasePath();
@@ -226,7 +226,7 @@ public function moveFileFromTmp($imageName)
226226
);
227227
}
228228

229-
return $imageName;
229+
return $returnRelativePath ? $baseImagePath : $imageName;
230230
}
231231

232232
/**

app/code/Magento/Catalog/Model/Product/Url.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,10 @@ public function getUrlInStore(\Magento\Catalog\Model\Product $product, $params =
101101
*/
102102
public function getProductUrl($product, $useSid = null)
103103
{
104-
if ($useSid === null) {
105-
$useSid = $this->sidResolver->getUseSessionInUrl();
106-
}
107-
108104
$params = [];
109105
if (!$useSid) {
110106
$params['_nosid'] = true;
111107
}
112-
113108
return $this->getUrl($product, $params);
114109
}
115110

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AddProductToCartActionGroup.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<!--
12+
NOTICE: AddSimpleProductToCart is deprecated.
13+
Please use AddSimpleProductToCartActionGroup instead.
14+
-->
1115
<actionGroup name="AddSimpleProductToCart">
1216
<annotations>
1317
<description>Navigates to the Storefront Product page. Then adds the Product to the Cart. Validates that the Success Message is present and correct.</description>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AddRelatedProductBySkuActionGroup">
12+
<annotations>
13+
<description>Adds the provided Product SKU as a Related Product on the Admin Product creation/edit page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="sku"/>
17+
</arguments>
18+
19+
<!--Scroll up to avoid error-->
20+
<scrollTo selector="{{AdminProductFormRelatedUpSellCrossSellSection.relatedDropdown}}" x="0" y="-100" stepKey="scrollTo"/>
21+
<conditionalClick selector="{{AdminProductFormRelatedUpSellCrossSellSection.relatedDropdown}}" dependentSelector="{{AdminProductFormRelatedUpSellCrossSellSection.relatedDependent}}" visible="false" stepKey="openDropDownIfClosedRelatedUpSellCrossSell"/>
22+
<click selector="{{AdminProductFormRelatedUpSellCrossSellSection.AddRelatedProductsButton}}" stepKey="clickAddRelatedProductButton"/>
23+
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
24+
<click selector="{{AdminProductGridFilterSection.filters}}" stepKey="openProductFilters"/>
25+
<fillField selector="{{AdminProductGridFilterSection.skuFilter}}" userInput="{{sku}}" stepKey="fillProductSkuFilter"/>
26+
<click selector="{{AdminProductGridFilterSection.applyFilters}}" stepKey="clickApplyFilters"/>
27+
<waitForPageLoad stepKey="waitForPageToLoad"/>
28+
<click selector="{{AdminProductModalSlideGridSection.productGridXRowYColumnButton('1', '1')}}" stepKey="selectProduct"/>
29+
<click selector="{{AdminAddRelatedProductsModalSection.AddSelectedProductsButton}}" stepKey="addRelatedProductSelected"/>
30+
<waitForElementNotVisible selector="{{AdminAddRelatedProductsModalSection.AddSelectedProductsButton}}" stepKey="waitForElementNotVisible"/>
31+
</actionGroup>
32+
</actionGroups>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AddSimpleProductToCartActionGroup">
12+
<annotations>
13+
<description>Navigates to the Storefront Product page. Then adds the Product to the Cart. Validates that the Success Message is present and correct.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="product" defaultValue="product"/>
17+
</arguments>
18+
19+
<amOnPage url="{{StorefrontProductPage.url(product.custom_attributes[url_key])}}" stepKey="goToProductPage"/>
20+
<waitForPageLoad stepKey="waitForProductPage"/>
21+
<click selector="{{StorefrontProductPageSection.addToCartBtn}}" stepKey="addToCart"/>
22+
<waitForElementNotVisible selector="{{StorefrontProductActionSection.addToCartButtonTitleIsAdding}}" stepKey="waitForElementNotVisibleAddToCartButtonTitleIsAdding"/>
23+
<waitForElementNotVisible selector="{{StorefrontProductActionSection.addToCartButtonTitleIsAdded}}" stepKey="waitForElementNotVisibleAddToCartButtonTitleIsAdded"/>
24+
<waitForElementVisible selector="{{StorefrontProductActionSection.addToCartButtonTitleIsAddToCart}}" stepKey="waitForElementVisibleAddToCartButtonTitleIsAddToCart"/>
25+
<waitForPageLoad stepKey="waitForPageLoad"/>
26+
<waitForElementVisible selector="{{StorefrontMessagesSection.success}}" time="30" stepKey="waitForProductAddedMessage"/>
27+
<see selector="{{StorefrontMessagesSection.success}}" userInput="You added {{product.name}} to your shopping cart." stepKey="seeAddToCartSuccessMessage"/>
28+
</actionGroup>
29+
</actionGroups>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AddUpSellProductBySkuActionGroup" extends="AddRelatedProductBySkuActionGroup">
12+
<annotations>
13+
<description>EXTENDS: AddRelatedProductBySkuActionGroup. Add the provided Product as an Up Sell Product.</description>
14+
</annotations>
15+
16+
<click selector="{{AdminProductFormRelatedUpSellCrossSellSection.AddUpSellProductsButton}}" stepKey="clickAddRelatedProductButton"/>
17+
<conditionalClick selector="{{AdminAddUpSellProductsModalSection.Modal}} {{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminAddUpSellProductsModalSection.Modal}} {{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
18+
<click selector="{{AdminAddUpSellProductsModalSection.Modal}} {{AdminProductGridFilterSection.filters}}" stepKey="openProductFilters"/>
19+
<fillField selector="{{AdminAddUpSellProductsModalSection.Modal}} {{AdminProductGridFilterSection.skuFilter}}" userInput="{{sku}}" stepKey="fillProductSkuFilter"/>
20+
<click selector="{{AdminAddUpSellProductsModalSection.Modal}} {{AdminProductGridFilterSection.applyFilters}}" stepKey="clickApplyFilters"/>
21+
<waitForPageLoad stepKey="waitForPageToLoad"/>
22+
<click selector="{{AdminAddUpSellProductsModalSection.Modal}}{{AdminProductModalSlideGridSection.productGridXRowYColumnButton('1', '1')}}" stepKey="selectProduct"/>
23+
<click selector="{{AdminAddUpSellProductsModalSection.AddSelectedProductsButton}}" stepKey="addRelatedProductSelected"/>
24+
<waitForPageLoad stepKey="waitForPageToLoad1"/>
25+
</actionGroup>
26+
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@
7373
<fillField selector="{{AdminCategorySEOSection.UrlKeyInput}}" userInput="{{categoryEntity.name_lwr}}" stepKey="enterURLKey"/>
7474
</actionGroup>
7575

76-
<!-- Save category form -->
76+
<!--
77+
NOTICE: saveCategoryForm is deprecated.
78+
Please use SaveCategoryFormActionGroup instead.
79+
-->
7780
<actionGroup name="saveCategoryForm">
7881
<annotations>
7982
<description>Requires navigation to the Category creation/edit page. Checks that the url contains the AdminCategoryPage url. Saves the Category.</description>
@@ -139,7 +142,10 @@
139142
</assertRegExp>
140143
</actionGroup>
141144

142-
<!-- Action to navigate to Media Gallery. Used in tests to cleanup uploaded images -->
145+
<!--
146+
NOTICE: navigateToMediaGallery is deprecated.
147+
Please use NavigateToMediaGalleryActionGroup instead.
148+
-->
143149
<actionGroup name="navigateToMediaGallery">
144150
<annotations>
145151
<description>Navigates to the category page and Opens the Media Gallery.</description>
@@ -170,7 +176,10 @@
170176
<seeInTitle userInput="{{categoryEntity.name}}" stepKey="seeCategoryNameInTitle"/>
171177
</actionGroup>
172178

173-
<!--Actions to delete category-->
179+
<!--
180+
NOTICE: DeleteCategory is deprecated.
181+
Please use DeleteCategoryActionGroup instead.
182+
-->
174183
<actionGroup name="DeleteCategory">
175184
<annotations>
176185
<description>Navigates to the category page and deletes the specified category.</description>
@@ -321,6 +330,10 @@
321330
<waitForPageLoad stepKey="waitForStoreViewChangeLoad"/>
322331
</actionGroup>
323332

333+
<!--
334+
NOTICE: navigateToCreatedCategory is deprecated.
335+
Please use NavigateToCreatedCategoryActionGroup instead.
336+
-->
324337
<actionGroup name="navigateToCreatedCategory">
325338
<annotations>
326339
<description>Navigates to category page, selects a category by specified category.</description>

0 commit comments

Comments
 (0)