Skip to content

Commit 7f14a5b

Browse files
[Magento Community Engineering] Community Contributions - 2.4-develop
- merged latest code from mainline branch
2 parents 727d3f2 + ecaa3b7 commit 7f14a5b

File tree

105 files changed

+1682
-222
lines changed

Some content is hidden

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

105 files changed

+1682
-222
lines changed

app/code/Magento/AsynchronousOperations/Model/MassSchedule.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class MassSchedule
5353
private $logger;
5454

5555
/**
56-
* @var OperationRepository
56+
* @var OperationRepositoryInterface
5757
*/
5858
private $operationRepository;
5959

@@ -75,7 +75,7 @@ class MassSchedule
7575
* @param AsyncResponseInterfaceFactory $asyncResponseFactory
7676
* @param BulkManagementInterface $bulkManagement
7777
* @param LoggerInterface $logger
78-
* @param OperationRepository $operationRepository
78+
* @param OperationRepositoryInterface $operationRepository
7979
* @param UserContextInterface $userContext
8080
* @param Encryptor $encryptor
8181
*/
@@ -85,7 +85,7 @@ public function __construct(
8585
AsyncResponseInterfaceFactory $asyncResponseFactory,
8686
BulkManagementInterface $bulkManagement,
8787
LoggerInterface $logger,
88-
OperationRepository $operationRepository,
88+
OperationRepositoryInterface $operationRepository,
8989
UserContextInterface $userContext,
9090
Encryptor $encryptor
9191
) {
@@ -137,7 +137,7 @@ public function publishMass($topicName, array $entitiesArray, $groupId = null, $
137137
$requestItem = $this->itemStatusInterfaceFactory->create();
138138

139139
try {
140-
$operation = $this->operationRepository->createByTopic($topicName, $entityParams, $groupId);
140+
$operation = $this->operationRepository->create($topicName, $entityParams, $groupId, $key);
141141
$operations[] = $operation;
142142
$requestItem->setId($key);
143143
$requestItem->setStatus(ItemStatusInterface::STATUS_ACCEPTED);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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\AsynchronousOperations\Model;
9+
10+
use Magento\AsynchronousOperations\Api\Data\OperationInterface;
11+
12+
/**
13+
* Repository interface to create operation
14+
*/
15+
interface OperationRepositoryInterface
16+
{
17+
/**
18+
* Create operation by topic, parameters and group ID
19+
*
20+
* @param string $topicName
21+
* @param array $entityParams
22+
* format: array(
23+
* '<arg1-name>' => '<arg1-value>',
24+
* '<arg2-name>' => '<arg2-value>',
25+
* )
26+
* @param string $groupId
27+
* @param int $operationId
28+
* @return OperationInterface
29+
*/
30+
public function create($topicName, $entityParams, $groupId, $operationId): OperationInterface;
31+
}

app/code/Magento/AsynchronousOperations/Model/ResourceModel/Operation/OperationRepository.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Magento\AsynchronousOperations\Api\Data\OperationInterface;
1212
use Magento\AsynchronousOperations\Api\Data\OperationInterfaceFactory;
13+
use Magento\AsynchronousOperations\Model\OperationRepositoryInterface;
1314
use Magento\Framework\MessageQueue\MessageValidator;
1415
use Magento\Framework\MessageQueue\MessageEncoder;
1516
use Magento\Framework\Serialize\Serializer\Json;
@@ -18,10 +19,10 @@
1819
/**
1920
* Create operation for list of bulk operations.
2021
*/
21-
class OperationRepository
22+
class OperationRepository implements OperationRepositoryInterface
2223
{
2324
/**
24-
* @var \Magento\AsynchronousOperations\Api\Data\OperationInterfaceFactory
25+
* @var OperationInterfaceFactory
2526
*/
2627
private $operationFactory;
2728

@@ -67,10 +68,14 @@ public function __construct(
6768
}
6869

6970
/**
70-
* @param $topicName
71-
* @param $entityParams
72-
* @param $groupId
73-
* @return mixed
71+
* Create operation by topic, parameters and group ID
72+
*
73+
* @param string $topicName
74+
* @param array $entityParams
75+
* @param string $groupId
76+
* @return OperationInterface
77+
* @deprecated No longer used.
78+
* @see create()
7479
*/
7580
public function createByTopic($topicName, $entityParams, $groupId)
7681
{
@@ -91,8 +96,16 @@ public function createByTopic($topicName, $entityParams, $groupId)
9196
],
9297
];
9398

94-
/** @var \Magento\AsynchronousOperations\Api\Data\OperationInterface $operation */
99+
/** @var OperationInterface $operation */
95100
$operation = $this->operationFactory->create($data);
96101
return $this->entityManager->save($operation);
97102
}
103+
104+
/**
105+
* @inheritDoc
106+
*/
107+
public function create($topicName, $entityParams, $groupId, $operationId): OperationInterface
108+
{
109+
return $this->createByTopic($topicName, $entityParams, $groupId);
110+
}
98111
}

app/code/Magento/AsynchronousOperations/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<preference for="Magento\AsynchronousOperations\Api\Data\BulkOperationsStatusInterface" type="Magento\AsynchronousOperations\Model\BulkStatus\Short" />
1919
<preference for="Magento\AsynchronousOperations\Api\Data\OperationSearchResultsInterface" type="Magento\AsynchronousOperations\Model\OperationSearchResults" />
2020
<preference for="Magento\AsynchronousOperations\Api\OperationRepositoryInterface" type="Magento\AsynchronousOperations\Model\OperationRepository" />
21+
<preference for="Magento\AsynchronousOperations\Model\OperationRepositoryInterface" type="Magento\AsynchronousOperations\Model\ResourceModel\Operation\OperationRepository" />
2122
<type name="Magento\Framework\EntityManager\MetadataPool">
2223
<arguments>
2324
<argument name="metadata" xsi:type="array">

app/code/Magento/Braintree/Test/Mftf/Test/CreateAnAdminOrderUsingBraintreePaymentTest1.xml renamed to app/code/Magento/Braintree/Test/Mftf/Test/CreateAnAdminOrderUsingBraintreePaymentTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11-
<test name="CreateAnAdminOrderUsingBraintreePaymentTest1">
11+
<test name="CreateAnAdminOrderUsingBraintreePaymentTest1Test">
1212
<annotations>
1313
<features value="Backend"/>
1414
<stories value="Creation an admin order using Braintree payment"/>

app/code/Magento/Braintree/Test/Mftf/Test/CretateAdminOrderWithOnlinePaymentIncludingTaxAndDiscount.xml renamed to app/code/Magento/Braintree/Test/Mftf/Test/CretateAdminOrderWithOnlinePaymentIncludingTaxAndDiscountTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11-
<test name="CreateAdminOrderPayedWithOnlinePaymentIncludingTaxAndDiscount">
11+
<test name="CreateAdminOrderPayedWithOnlinePaymentIncludingTaxAndDiscountTest">
1212
<annotations>
1313
<features value="Braintree"/>
1414
<stories value="Get access to a New Credit Memo Page from Invoice for Order payed with online payment via Admin"/>

app/code/Magento/Bundle/Test/Mftf/Test/AdminDeleteABundleProduct.xml renamed to app/code/Magento/Bundle/Test/Mftf/Test/AdminDeleteABundleProductTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11-
<test name="AdminDeleteABundleProduct">
11+
<test name="AdminDeleteABundleProductTest">
1212
<annotations>
1313
<features value="Bundle"/>
1414
<stories value="Admin list bundle products"/>

app/code/Magento/Bundle/Test/Mftf/Test/AdminFilterProductListByBundleProduct.xml renamed to app/code/Magento/Bundle/Test/Mftf/Test/AdminFilterProductListByBundleProductTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11-
<test name="AdminFilterProductListByBundleProduct">
11+
<test name="AdminFilterProductListByBundleProductTest">
1212
<annotations>
1313
<features value="Bundle"/>
1414
<stories value="Admin list bundle products"/>

app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGrid.xml renamed to app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGridTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11-
<test name="StorefrontBundleProductShownInCategoryListAndGrid">
11+
<test name="StorefrontBundleProductShownInCategoryListAndGridTest">
1212
<annotations>
1313
<features value="Bundle"/>
1414
<stories value="Bundle products list on Storefront"/>

app/code/Magento/Bundle/Test/Mftf/Test/StorefrontCheckBundleProductOptionTierPrices.xml renamed to app/code/Magento/Bundle/Test/Mftf/Test/StorefrontCheckBundleProductOptionTierPricesTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11-
<test name="StorefrontCheckBundleProductOptionTierPrices">
11+
<test name="StorefrontCheckBundleProductOptionTierPricesTest">
1212
<annotations>
1313
<features value="Bundle"/>
1414
<stories value="View bundle products"/>

app/code/Magento/Bundle/Test/Mftf/Test/StorefrontGoToDetailsPageWhenAddingToCartTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11-
<test name="StorefrontGoToDetailsPageWhenAddingToCart">
11+
<test name="StorefrontGoToDetailsPageWhenAddingToCartTest">
1212
<annotations>
1313
<features value="Bundle"/>
1414
<stories value="Bundle products list on Storefront"/>

app/code/Magento/Captcha/Test/Mftf/Test/CaptchaFormsDisplayingTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<scrollToTopOfPage stepKey="ScrollToTop"/>
6666
<click selector="{{CaptchaFormsDisplayingSection.captcha}}" stepKey="ClickToCloseCaptcha"/>
6767
</test>
68-
<test name="CaptchaWithDisabledGuestCheckout">
68+
<test name="CaptchaWithDisabledGuestCheckoutTest">
6969
<annotations>
7070
<features value="Captcha"/>
7171
<stories value="MC-5602 - CAPTCHA doesn't appear in login popup after refreshing page."/>

app/code/Magento/Catalog/Block/Product/View.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,9 @@ public function getQuantityValidators()
323323
*/
324324
public function getIdentities()
325325
{
326-
$identities = $this->getProduct()->getIdentities();
326+
$product = $this->getProduct();
327327

328-
return $identities;
328+
return $product ? $product->getIdentities() : [];
329329
}
330330

331331
/**

app/code/Magento/Catalog/Model/Category/DataProvider.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
* @api
4242
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
4343
* @SuppressWarnings(PHPMD.TooManyFields)
44+
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
4445
* @since 101.0.0
4546
*/
4647
class DataProvider extends ModifierPoolDataProvider
@@ -176,6 +177,10 @@ class DataProvider extends ModifierPoolDataProvider
176177
* @var AuthorizationInterface
177178
*/
178179
private $auth;
180+
/**
181+
* @var Image
182+
*/
183+
private $categoryImage;
179184

180185
/**
181186
* @param string $name
@@ -196,6 +201,7 @@ class DataProvider extends ModifierPoolDataProvider
196201
* @param ScopeOverriddenValue|null $scopeOverriddenValue
197202
* @param ArrayManager|null $arrayManager
198203
* @param FileInfo|null $fileInfo
204+
* @param Image|null $categoryImage
199205
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
200206
*/
201207
public function __construct(
@@ -216,7 +222,8 @@ public function __construct(
216222
?ArrayUtils $arrayUtils = null,
217223
ScopeOverriddenValue $scopeOverriddenValue = null,
218224
ArrayManager $arrayManager = null,
219-
FileInfo $fileInfo = null
225+
FileInfo $fileInfo = null,
226+
?Image $categoryImage = null
220227
) {
221228
$this->eavValidationRules = $eavValidationRules;
222229
$this->collection = $categoryCollectionFactory->create();
@@ -232,6 +239,7 @@ public function __construct(
232239
ObjectManager::getInstance()->get(ScopeOverriddenValue::class);
233240
$this->arrayManager = $arrayManager ?: ObjectManager::getInstance()->get(ArrayManager::class);
234241
$this->fileInfo = $fileInfo ?: ObjectManager::getInstance()->get(FileInfo::class);
242+
$this->categoryImage = $categoryImage ?? ObjectManager::getInstance()->get(Image::class);
235243

236244
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data, $pool);
237245
}
@@ -601,11 +609,7 @@ private function convertValues($category, $categoryData): array
601609
// phpcs:ignore Magento2.Functions.DiscouragedFunction
602610
$categoryData[$attributeCode][0]['name'] = basename($fileName);
603611

604-
if ($this->fileInfo->isBeginsWithMediaDirectoryPath($fileName)) {
605-
$categoryData[$attributeCode][0]['url'] = $fileName;
606-
} else {
607-
$categoryData[$attributeCode][0]['url'] = $category->getImageUrl($attributeCode);
608-
}
612+
$categoryData[$attributeCode][0]['url'] = $this->categoryImage->getUrl($category, $attributeCode);
609613

610614
$categoryData[$attributeCode][0]['size'] = isset($stat) ? $stat['size'] : 0;
611615
$categoryData[$attributeCode][0]['type'] = $mime;

app/code/Magento/Catalog/Model/Category/FileInfo.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,15 @@ private function getMediaDirectoryPathRelativeToBaseDirectoryPath(string $filePa
245245

246246
return $mediaDirectoryRelativeSubpath;
247247
}
248+
249+
/**
250+
* Get file relative path to media directory
251+
*
252+
* @param string $filename
253+
* @return string
254+
*/
255+
public function getRelativePathToMediaDirectory(string $filename): string
256+
{
257+
return $this->getFilePath($filename);
258+
}
248259
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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\Catalog\Model\Category;
9+
10+
use Magento\Catalog\Model\Category;
11+
use Magento\Framework\Exception\LocalizedException;
12+
use Magento\Framework\UrlInterface;
13+
use Magento\Store\Model\StoreManagerInterface;
14+
15+
/**
16+
* Category Image Service
17+
*/
18+
class Image
19+
{
20+
private const ATTRIBUTE_NAME = 'image';
21+
/**
22+
* @var FileInfo
23+
*/
24+
private $fileInfo;
25+
/**
26+
* @var StoreManagerInterface
27+
*/
28+
private $storeManager;
29+
30+
/**
31+
* Initialize dependencies.
32+
*
33+
* @param FileInfo $fileInfo
34+
* @param StoreManagerInterface $storeManager
35+
*/
36+
public function __construct(
37+
FileInfo $fileInfo,
38+
StoreManagerInterface $storeManager
39+
) {
40+
$this->fileInfo = $fileInfo;
41+
$this->storeManager = $storeManager;
42+
}
43+
/**
44+
* Resolve category image URL
45+
*
46+
* @param Category $category
47+
* @param string $attributeCode
48+
* @return string
49+
* @throws LocalizedException
50+
*/
51+
public function getUrl(Category $category, string $attributeCode = self::ATTRIBUTE_NAME): string
52+
{
53+
$url = '';
54+
$image = $category->getData($attributeCode);
55+
if ($image) {
56+
if (is_string($image)) {
57+
$store = $this->storeManager->getStore();
58+
$mediaBaseUrl = $store->getBaseUrl(UrlInterface::URL_TYPE_MEDIA);
59+
if ($this->fileInfo->isBeginsWithMediaDirectoryPath($image)) {
60+
$relativePath = $this->fileInfo->getRelativePathToMediaDirectory($image);
61+
$url = rtrim($mediaBaseUrl, '/') . '/' . ltrim($relativePath, '/');
62+
} elseif (substr($image, 0, 1) !== '/') {
63+
$url = rtrim($mediaBaseUrl, '/') . '/' . ltrim(FileInfo::ENTITY_MEDIA_PATH, '/') . '/' . $image;
64+
} else {
65+
$url = $image;
66+
}
67+
} else {
68+
throw new LocalizedException(
69+
__('Something went wrong while getting the image url.')
70+
);
71+
}
72+
}
73+
return $url;
74+
}
75+
}

app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ public function create($sku, ProductAttributeMediaGalleryEntryInterface $entry)
6161
$existingMediaGalleryEntries = $product->getMediaGalleryEntries();
6262
$existingEntryIds = [];
6363
if ($existingMediaGalleryEntries == null) {
64+
// set all media types if not specified
65+
if ($entry->getTypes() == null) {
66+
$entry->setTypes(array_keys($product->getMediaAttributes()));
67+
}
6468
$existingMediaGalleryEntries = [$entry];
6569
} else {
6670
foreach ($existingMediaGalleryEntries as $existingEntries) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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="AdminOpenProductImagesSectionActionGroup">
12+
<annotations>
13+
<description>Requires the navigation to the Product page. Opens 'Image and Videos' section.</description>
14+
</annotations>
15+
<conditionalClick selector="{{AdminProductImagesSection.productImagesToggle}}" dependentSelector="{{AdminProductImagesSection.imageUploadButton}}" visible="false" stepKey="openProductImagesSection"/>
16+
<waitForElementVisible selector="{{AdminProductImagesSection.imageUploadButton}}" stepKey="waitForImageUploadButton"/>
17+
</actionGroup>
18+
</actionGroups>

0 commit comments

Comments
 (0)