Skip to content

Commit a48144e

Browse files
committed
Merge remote-tracking branch 'mainline/2.4-develop' into MCP-958-2
2 parents ddb449e + 83f3d01 commit a48144e

File tree

73 files changed

+1474
-96
lines changed

Some content is hidden

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

73 files changed

+1474
-96
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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\Authorization\Test\Fixture;
9+
10+
use Magento\Authorization\Model\Acl\Role\Group;
11+
use Magento\Authorization\Model\ResourceModel\Role as RoleResource;
12+
use Magento\Authorization\Model\UserContextInterface;
13+
use Magento\Framework\DataObject;
14+
use Magento\SharedCatalog\Model\SharedCatalogFactory;
15+
use Magento\TestFramework\Fixture\Data\ProcessorInterface;
16+
use Magento\TestFramework\Fixture\RevertibleDataFixtureInterface;
17+
use Magento\Authorization\Model\RoleFactory;
18+
use Magento\Authorization\Model\RulesFactory;
19+
use Magento\User\Model\UserFactory;
20+
21+
/**
22+
* Creating a new admin role
23+
*/
24+
class Role implements RevertibleDataFixtureInterface
25+
{
26+
private const DEFAULT_DATA = [
27+
'role_name' => 'Role Name %uniqid%',
28+
'role_type' => Group::ROLE_TYPE,
29+
'user_id' => 0,
30+
'user_type' => UserContextInterface::USER_TYPE_ADMIN
31+
];
32+
33+
private const DEFAULT_DATA_RULES = [
34+
'id' => null,
35+
'role_id' => null,
36+
'resources' => ['Magento_Backend::all']
37+
];
38+
39+
/**
40+
* @var RoleFactory
41+
*/
42+
private $roleFactory;
43+
44+
/**
45+
* @var ProcessorInterface
46+
*/
47+
private $dataProcessor;
48+
49+
/**
50+
* @var RoleResource
51+
*/
52+
private $roleResourceModel;
53+
54+
/**
55+
* @var RulesFactory
56+
*/
57+
private $rulesFactory;
58+
59+
/**
60+
* @param RoleFactory $roleFactory
61+
* @param RoleResource $roleResourceModel
62+
* @param RulesFactory $rulesFactory
63+
* @param ProcessorInterface $dataProcessor
64+
*/
65+
public function __construct(
66+
RoleFactory $roleFactory,
67+
RoleResource $roleResourceModel,
68+
RulesFactory $rulesFactory,
69+
ProcessorInterface $dataProcessor
70+
) {
71+
$this->roleFactory = $roleFactory;
72+
$this->roleResourceModel = $roleResourceModel;
73+
$this->rulesFactory = $rulesFactory;
74+
$this->dataProcessor = $dataProcessor;
75+
}
76+
77+
/**
78+
* @inheritdoc
79+
*/
80+
public function apply(array $data = []): ?DataObject
81+
{
82+
$role = $this->roleFactory->create();
83+
$role->setData($this->prepareData(array_diff_key($data, self::DEFAULT_DATA_RULES)));
84+
$this->roleResourceModel->save($role);
85+
86+
$rules = $this->rulesFactory->create();
87+
$rules->setRoleId($role->getId() ?? null);
88+
$rules->setResources($data['resources'] ?? self::DEFAULT_DATA_RULES['resources']);
89+
$rules->saveRel();
90+
91+
return $role;
92+
}
93+
94+
/**
95+
* @inheritdoc
96+
*/
97+
public function revert(DataObject $data): void
98+
{
99+
$role = $this->roleFactory->create();
100+
$role->load($data->getId());
101+
102+
if ($role->getId() !== null) {
103+
$role->delete();
104+
}
105+
}
106+
107+
/**
108+
* Prepare admin role data
109+
*
110+
* @param array $data
111+
* @return array
112+
*/
113+
private function prepareData(array $data): array
114+
{
115+
$data = array_merge(self::DEFAULT_DATA, $data);
116+
return $this->dataProcessor->process($this, $data);
117+
}
118+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<severity value="MAJOR"/>
1616
<testCaseId value="MC-37515"/>
1717
<group value="Bundle"/>
18+
<group value="cloud_smoke"/>
1819
</annotations>
1920
<before>
2021
<createData entity="_defaultCategory" stepKey="createPreReqCategory"/>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<testCaseId value="MC-38683"/>
1717
<useCaseId value="MC-37663"/>
1818
<group value="Bundle"/>
19+
<group value="cloud_smoke"/>
1920
</annotations>
2021
<before>
2122
<createData entity="CustomerEntityOne" stepKey="createCustomer"/>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare (strict_types=1);
8+
namespace Magento\Catalog\Model\ResourceModel;
9+
10+
use Magento\Catalog\Api\Data\ProductInterface;
11+
use Magento\Framework\App\ResourceConnection;
12+
13+
/**
14+
* Get product type ID by product ID.
15+
*/
16+
class GetProductTypeById
17+
{
18+
/**
19+
* @var ResourceConnection
20+
*/
21+
private $resource;
22+
23+
/**
24+
* @param ResourceConnection $resource
25+
*/
26+
public function __construct(
27+
ResourceConnection $resource
28+
) {
29+
$this->resource = $resource;
30+
}
31+
32+
/**
33+
* Retrieve product type by its product ID
34+
*
35+
* @param int $productId
36+
* @return string
37+
*/
38+
public function execute(int $productId): string
39+
{
40+
$connection = $this->resource->getConnection();
41+
$productTable = $this->resource->getTableName('catalog_product_entity');
42+
43+
$select = $connection->select()
44+
->from(
45+
$productTable,
46+
ProductInterface::TYPE_ID
47+
)->where('entity_id = ?', $productId);
48+
49+
$result = $connection->fetchOne($select);
50+
return $result ?: '';
51+
}
52+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<group value="catalog"/>
1919
<severity value="MAJOR"/>
2020
<group value="pr_exclude"/>
21+
<group value="cloud_smoke"/>
2122
</annotations>
2223
<before>
2324
<actionGroup ref="AdminLoginActionGroup" stepKey="loginToAdminPanel"/>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<testCaseId value="MC-28534"/>
1919
<useCaseId value="MC-37347"/>
2020
<group value="catalog"/>
21+
<group value="cloud_smoke"/>
2122
</annotations>
2223

2324
<before>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<severity value="BLOCKER"/>
1818
<group value="catalog"/>
1919
<group value="mtf_migrated"/>
20+
<group value="cloud_smoke"/>
2021
</annotations>
2122
<before>
2223
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product/CollectionProcessor/StockProcessor.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ public function process(
5757
array $attributeNames,
5858
ContextInterface $context = null
5959
): Collection {
60-
if (!$this->stockConfig->isShowOutOfStock()) {
61-
$this->stockStatusResource->addIsInStockFilterToCollection($collection);
60+
$stockFlag = 'has_stock_status_filter';
61+
if (!$collection->hasFlag($stockFlag)) {
62+
$this->stockStatusResource->addStockDataToCollection($collection, !$this->stockConfig->isShowOutOfStock());
63+
$collection->setFlag($stockFlag, true);
6264
}
6365

6466
return $collection;

app/code/Magento/CatalogImportExport/Model/Export/Product.php

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,33 +38,33 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
3838
/**
3939
* Value that means all entities (e.g. websites, groups etc.)
4040
*/
41-
const VALUE_ALL = 'all';
41+
public const VALUE_ALL = 'all';
4242

4343
/**
4444
* Permanent column names.
4545
*
4646
* Names that begins with underscore is not an attribute. This name convention is for
4747
* to avoid interference with same attribute name.
4848
*/
49-
const COL_STORE = '_store';
49+
public const COL_STORE = '_store';
5050

51-
const COL_ATTR_SET = '_attribute_set';
51+
public const COL_ATTR_SET = '_attribute_set';
5252

53-
const COL_TYPE = '_type';
53+
public const COL_TYPE = '_type';
5454

55-
const COL_PRODUCT_WEBSITES = '_product_websites';
55+
public const COL_PRODUCT_WEBSITES = '_product_websites';
5656

57-
const COL_CATEGORY = '_category';
57+
public const COL_CATEGORY = '_category';
5858

59-
const COL_ROOT_CATEGORY = '_root_category';
59+
public const COL_ROOT_CATEGORY = '_root_category';
6060

61-
const COL_SKU = 'sku';
61+
public const COL_SKU = 'sku';
6262

63-
const COL_VISIBILITY = 'visibility';
63+
public const COL_VISIBILITY = 'visibility';
6464

65-
const COL_MEDIA_IMAGE = '_media_image';
65+
public const COL_MEDIA_IMAGE = '_media_image';
6666

67-
const COL_ADDITIONAL_ATTRIBUTES = 'additional_attributes';
67+
public const COL_ADDITIONAL_ATTRIBUTES = 'additional_attributes';
6868

6969
/**
7070
* Pairs of attribute set ID-to-name.
@@ -123,14 +123,14 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
123123
protected $_storeIdToCode = [];
124124

125125
/**
126-
* Website ID-to-code.
126+
* Array of Website ID-to-code.
127127
*
128128
* @var array
129129
*/
130130
protected $_websiteIdToCode = [];
131131

132132
/**
133-
* Attribute types
133+
* Attributes type
134134
*
135135
* @var array
136136
*/
@@ -284,6 +284,18 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
284284
'custom_design_to'
285285
];
286286

287+
/**
288+
* Image labels array
289+
*
290+
* @var array
291+
*/
292+
private $imageLabelAttributes = [
293+
'base_image_label',
294+
'small_image_label',
295+
'thumbnail_image_label',
296+
'swatch_image_label',
297+
];
298+
287299
/**
288300
* Attributes codes which are appropriate for export and not the part of additional_attributes.
289301
*
@@ -346,7 +358,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
346358
protected $metadataPool;
347359

348360
/**
349-
* Product entity link field
361+
* Link field of Product entity
350362
*
351363
* @var string
352364
*/
@@ -828,12 +840,12 @@ protected function getItemsPerPage()
828840
switch ($lastMemoryLimitLetter) {
829841
case 'g':
830842
$memoryLimit *= 1024;
831-
// fall-through intentional
832-
// no break
843+
// fall-through intentional
844+
// no break
833845
case 'm':
834846
$memoryLimit *= 1024;
835-
// fall-through intentional
836-
// no break
847+
// fall-through intentional
848+
// no break
837849
case 'k':
838850
$memoryLimit *= 1024;
839851
break;
@@ -962,6 +974,7 @@ protected function getExportData()
962974
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
963975
$dataRow = array_merge($dataRow, $stockItemRows[$productId]);
964976
}
977+
$this->updateGalleryImageData($dataRow, $rawData);
965978
$this->appendMultirowData($dataRow, $multirawData);
966979
if ($dataRow) {
967980
$exportData[] = $dataRow;
@@ -1370,6 +1383,29 @@ private function appendMultirowData(&$dataRow, $multiRawData)
13701383
return $dataRow;
13711384
}
13721385

1386+
/**
1387+
* Add image column if image label exists for all scope
1388+
*
1389+
* @param array $dataRow
1390+
* @param array $rawData
1391+
* @return void
1392+
*/
1393+
private function updateGalleryImageData(&$dataRow, $rawData)
1394+
{
1395+
$storeId = $dataRow['store_id'];
1396+
$productId = $dataRow['product_id'];
1397+
foreach ($this->imageLabelAttributes as $imageLabelCode) {
1398+
$imageAttributeCode = str_replace('_label', '', $imageLabelCode);
1399+
if ($storeId != Store::DEFAULT_STORE_ID
1400+
&& isset($dataRow[$imageLabelCode])
1401+
&& $dataRow[$imageLabelCode]
1402+
&& (!isset($dataRow[$imageAttributeCode]) || !$dataRow[$imageAttributeCode])
1403+
) {
1404+
$dataRow[$imageAttributeCode] = $rawData[$productId][Store::DEFAULT_STORE_ID][$imageAttributeCode];
1405+
}
1406+
}
1407+
}
1408+
13731409
/**
13741410
* Add multi row data to export
13751411
*

0 commit comments

Comments
 (0)