Skip to content

Commit 9529272

Browse files
committed
Merge branch '2.4-develop' of https://github.com/magento/magento2 into 31206_selected_shipping_method_does_not_contain_value_including_tax
2 parents 9126454 + c4003e8 commit 9529272

File tree

101 files changed

+4536
-3101
lines changed

Some content is hidden

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

101 files changed

+4536
-3101
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+
}

0 commit comments

Comments
 (0)