Skip to content

Commit aad32db

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into MC-34292
2 parents 7044294 + 323676f commit aad32db

File tree

125 files changed

+1780
-480
lines changed

Some content is hidden

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

125 files changed

+1780
-480
lines changed

.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ trim_trailing_whitespace = true
1010

1111
[*.md]
1212
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml,json}]
15+
indent_size = 2
16+
17+
[{composer, auth}.json]
18+
indent_size = 4

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public function __construct(
4242
}
4343

4444
/**
45+
* Construct block
46+
*
4547
* @return void
4648
*/
4749
protected function _construct()
@@ -51,6 +53,14 @@ protected function _construct()
5153

5254
parent::_construct();
5355

56+
$this->buttonList->update('save', 'label', __('Save Attribute'));
57+
$this->buttonList->update('save', 'class', 'save primary');
58+
$this->buttonList->update(
59+
'save',
60+
'data_attribute',
61+
['mage-init' => ['button' => ['event' => 'save', 'target' => '#edit_form']]]
62+
);
63+
5464
if ($this->getRequest()->getParam('popup')) {
5565
$this->buttonList->remove('back');
5666
if ($this->getRequest()->getParam('product_tab') != 'variations') {
@@ -64,6 +74,8 @@ protected function _construct()
6474
100
6575
);
6676
}
77+
$this->buttonList->update('reset', 'level', 10);
78+
$this->buttonList->update('save', 'class', 'save action-secondary');
6779
} else {
6880
$this->addButton(
6981
'save_and_edit_button',
@@ -79,14 +91,6 @@ protected function _construct()
7991
);
8092
}
8193

82-
$this->buttonList->update('save', 'label', __('Save Attribute'));
83-
$this->buttonList->update('save', 'class', 'save primary');
84-
$this->buttonList->update(
85-
'save',
86-
'data_attribute',
87-
['mage-init' => ['button' => ['event' => 'save', 'target' => '#edit_form']]]
88-
);
89-
9094
$entityAttribute = $this->_coreRegistry->registry('entity_attribute');
9195
if (!$entityAttribute || !$entityAttribute->getIsUserDefined()) {
9296
$this->buttonList->remove('delete');
@@ -96,14 +100,14 @@ protected function _construct()
96100
}
97101

98102
/**
99-
* {@inheritdoc}
103+
* @inheritdoc
100104
*/
101105
public function addButton($buttonId, $data, $level = 0, $sortOrder = 0, $region = 'toolbar')
102106
{
103107
if ($this->getRequest()->getParam('popup')) {
104108
$region = 'header';
105109
}
106-
parent::addButton($buttonId, $data, $level, $sortOrder, $region);
110+
return parent::addButton($buttonId, $data, $level, $sortOrder, $region);
107111
}
108112

109113
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public function getIdentities()
367367
$identities[] = $item->getIdentities();
368368
}
369369
}
370-
$identities = array_merge(...$identities);
370+
$identities = array_merge([], ...$identities);
371371

372372
return $identities;
373373
}

app/code/Magento/Catalog/Block/Product/ProductList/Related.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ public function getItems()
143143
*/
144144
public function getIdentities()
145145
{
146-
$identities = [[]];
146+
$identities = [];
147147
foreach ($this->getItems() as $item) {
148148
$identities[] = $item->getIdentities();
149149
}
150-
return array_merge(...$identities);
150+
return array_merge([], ...$identities);
151151
}
152152

153153
/**

app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,10 @@ public function getItemLimit($type = '')
267267
*/
268268
public function getIdentities()
269269
{
270-
$identities = array_map(function (DataObject $item) {
271-
return $item->getIdentities();
272-
}, $this->getItems()) ?: [[]];
273-
274-
return array_merge(...$identities);
270+
$identities = [];
271+
foreach ($this->getItems() as $item) {
272+
$identities[] = $item->getIdentities();
273+
}
274+
return array_merge([], ...$identities);
275275
}
276276
}

app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/TableResolver.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ public function afterGetTableName(
5555
string $result,
5656
$modelEntity
5757
) {
58-
if (!is_array($modelEntity) && $modelEntity === AbstractAction::MAIN_INDEX_TABLE) {
58+
if (!is_array($modelEntity) &&
59+
$modelEntity === AbstractAction::MAIN_INDEX_TABLE &&
60+
$this->storeManager->getStore()->getId()
61+
) {
5962
$catalogCategoryProductDimension = new Dimension(
6063
\Magento\Store\Model\Store::ENTITY,
6164
$this->storeManager->getStore()->getId()

app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,14 @@ private function getCategoryIdsFromIndex(array $productIds): array
270270
);
271271
$categoryIds[] = $storeCategories;
272272
}
273-
$categoryIds = array_merge(...$categoryIds);
273+
$categoryIds = array_merge([], ...$categoryIds);
274274

275275
$parentCategories = [$categoryIds];
276276
foreach ($categoryIds as $categoryId) {
277277
$parentIds = explode('/', $this->getPathFromCategoryId($categoryId));
278278
$parentCategories[] = $parentIds;
279279
}
280-
$categoryIds = array_unique(array_merge(...$parentCategories));
280+
$categoryIds = array_unique(array_merge([], ...$parentCategories));
281281

282282
return $categoryIds;
283283
}

app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ protected function _fillTemporaryFlatTable(array $tables, $storeId, $valueFieldS
261261

262262
$select->from(
263263
['et' => $entityTemporaryTableName],
264-
array_merge(...$allColumns)
264+
array_merge([], ...$allColumns)
265265
)->joinInner(
266266
['e' => $this->resource->getTableName('catalog_product_entity')],
267267
'e.entity_id = et.entity_id',
@@ -306,7 +306,7 @@ protected function _fillTemporaryFlatTable(array $tables, $storeId, $valueFieldS
306306
$allColumns[] = $columnValueNames;
307307
}
308308
}
309-
$sql = $select->insertFromSelect($temporaryFlatTableName, array_merge(...$allColumns), false);
309+
$sql = $select->insertFromSelect($temporaryFlatTableName, array_merge([], ...$allColumns), false);
310310
$this->_connection->query($sql);
311311
}
312312

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -836,10 +836,7 @@ public function getStoreIds()
836836
$storeIds[] = $websiteStores;
837837
}
838838
}
839-
if ($storeIds) {
840-
$storeIds = array_merge(...$storeIds);
841-
}
842-
$this->setStoreIds($storeIds);
839+
$this->setStoreIds(array_merge([], ...$storeIds));
843840
}
844841
return $this->getData('store_ids');
845842
}

app/code/Magento/Catalog/Model/Product/Price/TierPriceStorage.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
use Magento\Catalog\Model\Product\Price\Validation\TierPriceValidator;
1313
use Magento\Catalog\Model\ProductIdLocatorInterface;
1414

15-
/**
16-
* Tier price storage.
17-
*/
1815
class TierPriceStorage implements TierPriceStorageInterface
1916
{
2017
/**
@@ -220,7 +217,7 @@ private function retrieveAffectedIds(array $skus): array
220217
$affectedIds[] = array_keys($productId);
221218
}
222219

223-
return $affectedIds ? array_unique(array_merge(...$affectedIds)) : [];
220+
return array_unique(array_merge([], ...$affectedIds));
224221
}
225222

226223
/**

app/code/Magento/Catalog/Model/ProductLink/ProductLinkQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private function extractRequestedLinkTypes(array $criteria): array
103103
if (count($linkTypesToLoad) === 1) {
104104
$linkTypesToLoad = $linkTypesToLoad[0];
105105
} else {
106-
$linkTypesToLoad = array_merge(...$linkTypesToLoad);
106+
$linkTypesToLoad = array_merge([], ...$linkTypesToLoad);
107107
}
108108
$linkTypesToLoad = array_flip($linkTypesToLoad);
109109
$linkTypes = array_filter(

app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderComposite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function build(int $productId, int $storeId) : array
3333
foreach ($this->linkedProductSelectBuilder as $productSelectBuilder) {
3434
$selects[] = $productSelectBuilder->build($productId, $storeId);
3535
}
36-
$selects = array_merge(...$selects);
36+
$selects = array_merge([], ...$selects);
3737

3838
return $selects;
3939
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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\Test\Unit\Model\Indexer\Category\Product\Plugin;
9+
10+
use Magento\Catalog\Model\Indexer\Category\Product\Plugin\TableResolver;
11+
use Magento\Framework\App\ResourceConnection;
12+
use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver;
13+
use Magento\Store\Model\Store;
14+
use Magento\Store\Model\StoreManagerInterface;
15+
use PHPUnit\Framework\TestCase;
16+
17+
class TableResolverTest extends TestCase
18+
{
19+
/**
20+
* Tests replacing catalog_category_product_index table name
21+
*
22+
* @param int $storeId
23+
* @param string $tableName
24+
* @param string $expected
25+
* @dataProvider afterGetTableNameDataProvider
26+
*/
27+
public function testAfterGetTableName(int $storeId, string $tableName, string $expected): void
28+
{
29+
$storeManagerMock = $this->getMockForAbstractClass(StoreManagerInterface::class);
30+
31+
$storeMock = $this->getMockBuilder(Store::class)
32+
->onlyMethods(['getId'])
33+
->disableOriginalConstructor()
34+
->getMock();
35+
$storeMock->method('getId')
36+
->willReturn($storeId);
37+
38+
$storeManagerMock->method('getStore')->willReturn($storeMock);
39+
40+
$tableResolverMock = $this->getMockBuilder(IndexScopeResolver::class)
41+
->disableOriginalConstructor()
42+
->getMock();
43+
$tableResolverMock->method('resolve')->willReturn('catalog_category_product_index_store1');
44+
45+
$subjectMock = $this->getMockBuilder(ResourceConnection::class)
46+
->disableOriginalConstructor()
47+
->getMock();
48+
49+
$model = new TableResolver($storeManagerMock, $tableResolverMock);
50+
51+
$this->assertEquals(
52+
$expected,
53+
$model->afterGetTableName($subjectMock, $tableName, 'catalog_category_product_index')
54+
);
55+
}
56+
57+
/**
58+
* Data provider for testAfterGetTableName
59+
*
60+
* @return array
61+
*/
62+
public function afterGetTableNameDataProvider(): array
63+
{
64+
return [
65+
[
66+
'storeId' => 1,
67+
'tableName' => 'catalog_category_product_index',
68+
'expected' => 'catalog_category_product_index_store1'
69+
],
70+
[
71+
'storeId' => 0,
72+
'tableName' => 'catalog_category_product_index',
73+
'expected' => 'catalog_category_product_index'
74+
],
75+
];
76+
}
77+
}

app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder/Attribute.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ function (AggregationValueInterface $value) {
155155
return [];
156156
}
157157

158-
return $this->attributeOptionProvider->getOptions(\array_merge(...$attributeOptionIds), $storeId, $attributes);
158+
return $this->attributeOptionProvider->getOptions(
159+
\array_merge([], ...$attributeOptionIds),
160+
$storeId,
161+
$attributes
162+
);
159163
}
160164
}

app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/LayerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function build(AggregationInterface $aggregation, ?int $storeId): array
3636
foreach ($this->builders as $builder) {
3737
$layers[] = $builder->build($aggregation, $storeId);
3838
}
39-
$layers = \array_merge(...$layers);
39+
$layers = \array_merge([], ...$layers);
4040

4141
return \array_filter($layers);
4242
}

app/code/Magento/CatalogGraphQl/Model/AttributesJoiner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function getQueryFields(FieldNode $fieldNode, ResolveInfo $resolveInfo):
8888
}
8989
}
9090
if ($fragmentFields) {
91-
$selectedFields = array_merge($selectedFields, array_merge(...$fragmentFields));
91+
$selectedFields = array_merge([], $selectedFields, ...$fragmentFields);
9292
}
9393
$this->setSelectionsForFieldNode($fieldNode, array_unique($selectedFields));
9494
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/SearchCriteria/CollectionProcessor/FilterProcessor/CategoryFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function apply(Filter $filter, AbstractDb $collection)
6464
$collection->addCategoryFilter($category);
6565
}
6666

67-
$categoryProductIds = array_unique(array_merge(...$categoryProducts));
67+
$categoryProductIds = array_unique(array_merge([], ...$categoryProducts));
6868
$collection->addIdFilter($categoryProductIds);
6969
return true;
7070
}

0 commit comments

Comments
 (0)