Skip to content

Commit 1b7c628

Browse files
committed
Merge branch '2.4-develop' into B2B-2033
2 parents 44cd539 + c4003e8 commit 1b7c628

File tree

97 files changed

+4417
-2940
lines changed

Some content is hidden

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

97 files changed

+4417
-2940
lines changed

app/code/Magento/Backend/view/adminhtml/templates/widget/grid/extended.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ script;
303303
script;
304304
endif;
305305

306-
if (strpos($block->getRowClickCallback(), 'order.') !== false):
306+
if ($block->getRowClickCallback() && strpos($block->getRowClickCallback(), 'order.') !== false):
307307
$scriptString .= <<<script
308308
309309
deps.push('Magento_Sales/order/create/form')

app/code/Magento/Backend/view/adminhtml/templates/widget/tabs.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
endif;
2626
?>
2727
<?php $_tabClass = 'tab-item-link ' . $block->getTabClass($_tab) . ' ' .
28-
(preg_match('/\s?ajax\s?/', $_tab->getClass()) ? 'notloaded' : '') ?>
28+
(preg_match('/\s?ajax\s?/', $_tab->getClass() ?? '') ? 'notloaded' : '') ?>
2929
<?php $_tabType = (!preg_match('/\s?ajax\s?/', $_tabClass) && $block->getTabUrl($_tab) != '#') ?
3030
'link' : '' ?>
3131
<?php $_tabHref = $block->getTabUrl($_tab) == '#' ? '#' . $block->getTabId($_tab) . '_content' :

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

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\Catalog\Model\Indexer\Product\Flat;
77

88
use Magento\Catalog\Model\Indexer\Product\Flat\Table\BuilderInterfaceFactory;
9+
use Magento\Framework\App\ObjectManager;
10+
use Magento\Framework\EntityManager\MetadataPool;
911
use Magento\Store\Model\Store;
1012

1113
/**
@@ -26,7 +28,7 @@ class TableBuilder
2628
protected $_connection;
2729

2830
/**
29-
* @var \Magento\Framework\EntityManager\MetadataPool
31+
* @var MetadataPool
3032
*/
3133
protected $metadataPool;
3234

@@ -46,17 +48,20 @@ class TableBuilder
4648
* @param \Magento\Catalog\Helper\Product\Flat\Indexer $productIndexerHelper
4749
* @param \Magento\Framework\App\ResourceConnection $resource
4850
* @param BuilderInterfaceFactory|null $tableBuilderFactory
51+
* @param MetadataPool|null $metadataPool
4952
*/
5053
public function __construct(
5154
\Magento\Catalog\Helper\Product\Flat\Indexer $productIndexerHelper,
5255
\Magento\Framework\App\ResourceConnection $resource,
53-
BuilderInterfaceFactory $tableBuilderFactory = null
56+
BuilderInterfaceFactory $tableBuilderFactory = null,
57+
MetadataPool $metadataPool = null
5458
) {
5559
$this->_productIndexerHelper = $productIndexerHelper;
5660
$this->resource = $resource;
5761
$this->_connection = $resource->getConnection();
58-
$this->tableBuilderFactory = $tableBuilderFactory ?: \Magento\Framework\App\ObjectManager::getInstance()
62+
$this->tableBuilderFactory = $tableBuilderFactory ?? ObjectManager::getInstance()
5963
->get(BuilderInterfaceFactory::class);
64+
$this->metadataPool = $metadataPool ?? ObjectManager::getInstance()->get(MetadataPool::class);
6065
}
6166

6267
/**
@@ -73,7 +78,7 @@ public function build($storeId, $changedIds, $valueFieldSuffix)
7378
$attributes = $this->_productIndexerHelper->getAttributes();
7479
$eavAttributes = $this->_productIndexerHelper->getTablesStructure($attributes);
7580
$entityTableColumns = $eavAttributes[$entityTableName];
76-
$linkField = $this->getMetadataPool()
81+
$linkField = $this->metadataPool
7782
->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class)
7883
->getLinkField();
7984

@@ -226,7 +231,7 @@ protected function _fillTemporaryEntityTable($tableName, array $columns, array $
226231
if (!empty($columns)) {
227232
$select = $this->_connection->select();
228233
$temporaryEntityTable = $this->_getTemporaryTableName($tableName);
229-
$metadata = $this->getMetadataPool()->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class);
234+
$metadata = $this->metadataPool->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class);
230235
$idsColumns = array_unique([$metadata->getLinkField(), 'entity_id', 'type_id', 'attribute_set_id']);
231236

232237
$columns = array_merge($idsColumns, array_keys($columns));
@@ -269,6 +274,7 @@ protected function _addPrimaryKeyToTable($tableName, $columnName = 'entity_id')
269274
* @param int $storeId
270275
* @return void
271276
* @throws \Exception
277+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
272278
*/
273279
protected function _fillTemporaryTable(
274280
$tableName,
@@ -278,7 +284,11 @@ protected function _fillTemporaryTable(
278284
$storeId
279285
) {
280286
if (!empty($tableColumns)) {
281-
$columnsChunks = array_chunk($tableColumns, Action\Indexer::ATTRIBUTES_CHUNK_SIZE / 2, true);
287+
$columnsChunks = array_chunk(
288+
$tableColumns,
289+
intdiv(Action\Indexer::ATTRIBUTES_CHUNK_SIZE, 2),
290+
true
291+
);
282292

283293
$entityTableName = $this->_productIndexerHelper->getTable('catalog_product_entity');
284294
$entityTemporaryTableName = $this->_getTemporaryTableName($entityTableName);
@@ -288,7 +298,7 @@ protected function _fillTemporaryTable(
288298

289299
$flatColumns = $this->_productIndexerHelper->getFlatColumns();
290300
$defaultStoreId = Store::DEFAULT_STORE_ID;
291-
$linkField = $this->getMetadataPool()
301+
$linkField = $this->metadataPool
292302
->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class)
293303
->getLinkField();
294304

@@ -368,19 +378,4 @@ protected function _fillTemporaryTable(
368378
}
369379
}
370380
}
371-
372-
/**
373-
* Get Metadata Pool
374-
*
375-
* @return \Magento\Framework\EntityManager\MetadataPool
376-
* @deprecated 102.0.0
377-
*/
378-
private function getMetadataPool()
379-
{
380-
if (null === $this->metadataPool) {
381-
$this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance()
382-
->get(\Magento\Framework\EntityManager\MetadataPool::class);
383-
}
384-
return $this->metadataPool;
385-
}
386381
}

app/code/Magento/Catalog/Model/Product/Option/Type/Date.php

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
/**
1212
* Catalog product option date type
1313
*
14-
* @author Magento Core Team <core@magentocommerce.com>
1514
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1615
*/
1716
class Date extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
@@ -218,32 +217,36 @@ public function prepareForCart()
218217
public function getFormattedOptionValue($optionValue)
219218
{
220219
if ($this->_formattedOptionValue === null) {
221-
if ($this->getOption()->getType() == ProductCustomOptionInterface::OPTION_TYPE_DATE) {
222-
$result = $this->_localeDate->formatDateTime(
223-
new \DateTime($optionValue),
224-
\IntlDateFormatter::MEDIUM,
225-
\IntlDateFormatter::NONE,
226-
null,
227-
'UTC'
228-
);
229-
} elseif ($this->getOption()->getType() == ProductCustomOptionInterface::OPTION_TYPE_DATE_TIME) {
230-
$result = $this->_localeDate->formatDateTime(
231-
new \DateTime($optionValue),
232-
\IntlDateFormatter::SHORT,
233-
\IntlDateFormatter::SHORT,
234-
null,
235-
'UTC'
236-
);
237-
} elseif ($this->getOption()->getType() == ProductCustomOptionInterface::OPTION_TYPE_TIME) {
238-
$result = $this->_localeDate->formatDateTime(
239-
new \DateTime($optionValue),
240-
\IntlDateFormatter::NONE,
241-
\IntlDateFormatter::SHORT,
242-
null,
243-
'UTC'
244-
);
245-
} else {
246-
$result = $optionValue;
220+
switch ($this->getOption()->getType()) {
221+
case ProductCustomOptionInterface::OPTION_TYPE_DATE:
222+
$result = $this->_localeDate->formatDateTime(
223+
new \DateTime($optionValue),
224+
\IntlDateFormatter::MEDIUM,
225+
\IntlDateFormatter::NONE,
226+
null,
227+
'UTC'
228+
);
229+
break;
230+
case ProductCustomOptionInterface::OPTION_TYPE_DATE_TIME:
231+
$result = $this->_localeDate->formatDateTime(
232+
new \DateTime($optionValue),
233+
\IntlDateFormatter::SHORT,
234+
\IntlDateFormatter::SHORT,
235+
null,
236+
'UTC'
237+
);
238+
break;
239+
case ProductCustomOptionInterface::OPTION_TYPE_TIME:
240+
$result = $this->_localeDate->formatDateTime(
241+
new \DateTime($optionValue),
242+
\IntlDateFormatter::NONE,
243+
\IntlDateFormatter::SHORT,
244+
null,
245+
'UTC'
246+
);
247+
break;
248+
default:
249+
$result = $optionValue;
247250
}
248251
$this->_formattedOptionValue = $result;
249252
}
@@ -302,8 +305,8 @@ public function prepareOptionValueForRequest($optionValue)
302305
$infoBuyRequest = $confItem->getOptionByCode('info_buyRequest');
303306
try {
304307
$value = $this->serializer->unserialize($infoBuyRequest->getValue());
305-
if (is_array($value) && isset($value['options']) && isset($value['options'][$this->getOption()->getId()])
306-
) {
308+
309+
if (is_array($value) && isset($value['options'][$this->getOption()->getId()])) {
307310
return $value['options'][$this->getOption()->getId()];
308311
} else {
309312
return ['date_internal' => $optionValue];
@@ -340,12 +343,10 @@ public function is24hTimeFormat()
340343
*/
341344
public function getYearStart()
342345
{
343-
$_range = explode(',', $this->getConfigData('year_range'));
344-
if (isset($_range[0]) && !empty($_range[0])) {
345-
return $_range[0];
346-
} else {
347-
return date('Y');
348-
}
346+
$_range = $this->getConfigData('year_range') !== null
347+
? explode(',', $this->getConfigData('year_range'))
348+
: [];
349+
return (isset($_range[0]) && !empty($_range[0])) ? $_range[0] : date('Y');
349350
}
350351

351352
/**
@@ -355,12 +356,10 @@ public function getYearStart()
355356
*/
356357
public function getYearEnd()
357358
{
358-
$_range = explode(',', $this->getConfigData('year_range'));
359-
if (isset($_range[1]) && !empty($_range[1])) {
360-
return $_range[1];
361-
} else {
362-
return date('Y');
363-
}
359+
$_range = $this->getConfigData('year_range') !== null
360+
? explode(',', $this->getConfigData('year_range'))
361+
: [];
362+
return (isset($_range[1]) && !empty($_range[1])) ? $_range[1] : date('Y');
364363
}
365364

366365
/**

app/code/Magento/Catalog/Model/Product/Option/Type/Text.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function validateUserValue($values)
5858
parent::validateUserValue($values);
5959

6060
$option = $this->getOption();
61-
$value = trim($this->getUserValue());
61+
$value = $this->getUserValue() !== null ? trim($this->getUserValue()) : '';
6262

6363
// Check requires option to have some value
6464
if (strlen($value) == 0 && $option->getIsRequire() && !$this->getSkipCheckRequiredOption()) {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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\Product;
9+
10+
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
11+
use Magento\Eav\Model\ReservedAttributeCheckerInterface;
12+
13+
/**
14+
* Adapter for \Magento\Catalog\Model\Product\ReservedAttributeList
15+
*
16+
* Is created to implement proper interface and to use api class ReservedAttributeList
17+
* while keeping it backward compatible
18+
* @see \Magento\Catalog\Model\Product\ReservedAttributeList
19+
*/
20+
class ReservedAttributeCheckerAdapter implements ReservedAttributeCheckerInterface
21+
{
22+
/**
23+
* @var ReservedAttributeList
24+
*/
25+
private $reservedAttributeList;
26+
27+
/**
28+
* @param ReservedAttributeList $reservedAttributeList
29+
*/
30+
public function __construct(
31+
ReservedAttributeList $reservedAttributeList
32+
) {
33+
$this->reservedAttributeList = $reservedAttributeList;
34+
}
35+
36+
/**
37+
* @inheritdoc
38+
*/
39+
public function isReservedAttribute(AbstractAttribute $attribute): bool
40+
{
41+
return $this->reservedAttributeList->isReservedAttribute($attribute);
42+
}
43+
}

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/CatalogEavValidationRulesTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ public function testBuild($frontendInput, $frontendClass, array $eavConfig, arra
5050
$attribute->expects($this->once())
5151
->method('getFrontendInput')
5252
->willReturn($frontendInput);
53-
$attribute->expects($this->once())
54-
->method('getFrontendClass')
53+
$attribute->method('getFrontendClass')
5554
->willReturn($frontendClass);
5655

5756
$this->assertEquals($expectedResult, $this->catalogEavValidationRules->build($attribute, $eavConfig));

app/code/Magento/Catalog/Ui/DataProvider/CatalogEavValidationRules.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,18 @@ public function build(ProductAttributeInterface $attribute, array $data)
3333
$rules['validate-zero-or-greater'] = true;
3434
}
3535

36-
$validationClasses = explode(' ', $attribute->getFrontendClass());
36+
$validationClasses = $attribute->getFrontendClass()
37+
? explode(' ', $attribute->getFrontendClass())
38+
: [];
3739

3840
foreach ($validationClasses as $class) {
3941
if (preg_match('/^maximum-length-(\d+)$/', $class, $matches)) {
42+
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
4043
$rules = array_merge($rules, ['max_text_length' => $matches[1]]);
4144
continue;
4245
}
4346
if (preg_match('/^minimum-length-(\d+)$/', $class, $matches)) {
47+
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
4448
$rules = array_merge($rules, ['min_text_length' => $matches[1]]);
4549
continue;
4650
}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<preference for="Magento\Catalog\Model\Indexer\Product\Price\UpdateIndexInterface" type="Magento\Catalog\Model\Indexer\Product\Price\InvalidateIndex" />
7474
<preference for="Magento\Catalog\Model\Product\Gallery\ImagesConfigFactoryInterface" type="Magento\Catalog\Model\Product\Gallery\ImagesConfigFactory" />
7575
<preference for="Magento\Catalog\Model\Product\Configuration\Item\ItemResolverInterface" type="Magento\Catalog\Model\Product\Configuration\Item\ItemResolverComposite" />
76-
<preference for="Magento\Catalog\Api\Data\MassActionInterface" type="\Magento\Catalog\Model\MassAction" />
76+
<preference for="Magento\Catalog\Api\Data\MassActionInterface" type="Magento\Catalog\Model\MassAction" />
7777
<preference for="Magento\Catalog\Model\ProductLink\Data\ListCriteriaInterface" type="Magento\Catalog\Model\ProductLink\Data\ListCriteria" />
7878
<preference for="Magento\Catalog\Api\CategoryListDeleteBySkuInterface" type="Magento\Catalog\Model\CategoryLinkRepository"/>
7979
<type name="Magento\Customer\Model\ResourceModel\Visitor">
@@ -1333,4 +1333,13 @@
13331333
<argument name="imageResizeScheduler" xsi:type="object">Magento\MediaStorage\Service\ImageResizeScheduler\Proxy</argument>
13341334
</arguments>
13351335
</type>
1336+
<type name="Magento\Eav\Model\ReservedAttributeChecker">
1337+
<arguments>
1338+
<argument name="validators" xsi:type="array">
1339+
<item name="catalog_product" xsi:type="array">
1340+
<item name="product_reserved_attribute_codes" xsi:type="object">\Magento\Catalog\Model\Product\ReservedAttributeCheckerAdapter</item>
1341+
</item>
1342+
</argument>
1343+
</arguments>
1344+
</type>
13361345
</config>

app/code/Magento/Catalog/view/frontend/templates/product/list.phtml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ $_helper = $block->getData('outputHelper');
8787
data-product-sku="<?= $escaper->escapeHtml($_product->getSku()) ?>"
8888
action="<?= $escaper->escapeUrl($postParams['action']) ?>"
8989
method="post">
90-
<?php $optionsData = $block->getData('viewModel')->getOptionsData($_product); ?>
91-
<?php foreach ($optionsData as $optionItem): ?>
90+
<?php $options = $block->getData('viewModel')->getOptionsData($_product); ?>
91+
<?php foreach ($options as $optionItem): ?>
9292
<input type="hidden"
9393
name="<?= $escaper->escapeHtml($optionItem['name']) ?>"
9494
value="<?= $escaper->escapeHtml($optionItem['value']) ?>">
@@ -119,7 +119,7 @@ $_helper = $block->getData('outputHelper');
119119
<?php endif; ?>
120120
<?php endif; ?>
121121
</div>
122-
<?= strpos($pos, $viewMode . '-primary') ?
122+
<?= ($pos && strpos($pos, $viewMode . '-primary')) ?
123123
/* @noEscape */ $secureRenderer->renderStyleAsTag(
124124
$position,
125125
'product-item-info_' . $_product->getId() . ' div.actions-primary'
@@ -129,7 +129,7 @@ $_helper = $block->getData('outputHelper');
129129
<?= $addToBlock->setProduct($_product)->getChildHtml() ?>
130130
<?php endif; ?>
131131
</div>
132-
<?= strpos($pos, $viewMode . '-secondary') ?
132+
<?= ($pos && strpos($pos, $viewMode . '-secondary')) ?
133133
/* @noEscape */ $secureRenderer->renderStyleAsTag(
134134
$position,
135135
'product-item-info_' . $_product->getId() . ' div.actions-secondary'
@@ -150,7 +150,7 @@ $_helper = $block->getData('outputHelper');
150150
</div>
151151
</div>
152152
</div>
153-
<?= strpos($pos, $viewMode . '-actions') ?
153+
<?= ($pos && strpos($pos, $viewMode . '-actions')) ?
154154
/* @noEscape */ $secureRenderer->renderStyleAsTag(
155155
$position,
156156
'product-item-info_' . $_product->getId() . ' div.product-item-actions'
@@ -160,6 +160,7 @@ $_helper = $block->getData('outputHelper');
160160
</ol>
161161
</div>
162162
<?= $block->getChildBlock('toolbar')->setIsBottom(true)->toHtml() ?>
163+
<?php // phpcs:ignore Magento2.Legacy.PhtmlTemplate ?>
163164
<script type="text/x-magento-init">
164165
{
165166
"[data-role=tocart-form], .form.map.checkout": {

0 commit comments

Comments
 (0)