Skip to content

Commit 21f4acd

Browse files
committed
Merge branch '2.4-develop' of https://github.com/magento-commerce/magento2ce into ACP2E-111
2 parents 92f5674 + e88d5bd commit 21f4acd

File tree

30 files changed

+1338
-84
lines changed

30 files changed

+1338
-84
lines changed

app/code/Magento/Backup/Test/Mftf/Test/AdminCreateAndDeleteBackupsTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
<severity value="CRITICAL"/>
1818
<testCaseId value="MAGETWO-94176"/>
1919
<group value="backup"/>
20+
<skip>
21+
<issueId value="DEPRECATED">Magento backup functionality is deprecated</issueId>
22+
</skip>
2023
</annotations>
2124
<before>
2225
<magentoCLI command="config:set {{EnableBackupFunctionality.path}} {{EnableBackupFunctionality.value}}" stepKey="setEnableBackup"/>

app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/View/Items/Renderer.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
class Renderer extends \Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer
2020
{
2121
/**
22-
* Serializer
23-
*
2422
* @var Json
2523
*/
2624
private $serializer;
@@ -211,7 +209,7 @@ public function getValueHtml($item)
211209
if (!$this->isChildCalculated($item)) {
212210
$attributes = $this->getSelectionAttributes($item);
213211
if ($attributes) {
214-
$result .= " " . $this->getItem()->getOrder()->formatPrice($attributes['price']);
212+
$result .= " " . $this->getItem()->getOrder()->formatBasePrice($attributes['price']);
215213
}
216214
}
217215
return $result;

app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
class Renderer extends \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer
1717
{
1818
/**
19-
* Serializer
20-
*
2119
* @var Json
2220
*/
2321
private $serializer;
@@ -43,7 +41,10 @@ public function __construct(
4341
}
4442

4543
/**
44+
* Check if shipment type (invoice etc) is separate
45+
*
4646
* @param mixed $item
47+
*
4748
* @return bool
4849
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
4950
*/
@@ -79,7 +80,10 @@ public function isShipmentSeparately($item = null)
7980
}
8081

8182
/**
83+
* Check if sub product calculations are present
84+
*
8285
* @param mixed $item
86+
*
8387
* @return bool
8488
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
8589
*/
@@ -117,7 +121,10 @@ public function isChildCalculated($item = null)
117121
}
118122

119123
/**
124+
* Get bundle selection attributes
125+
*
120126
* @param mixed $item
127+
*
121128
* @return mixed|null
122129
*/
123130
public function getSelectionAttributes($item)
@@ -134,14 +141,17 @@ public function getSelectionAttributes($item)
134141
}
135142

136143
/**
144+
* Get html of bundle selection attributes
145+
*
137146
* @param mixed $item
147+
*
138148
* @return string
139149
*/
140150
public function getValueHtml($item)
141151
{
142152
if ($attributes = $this->getSelectionAttributes($item)) {
143153
return sprintf('%d', $attributes['qty']) . ' x ' . $this->escapeHtml($item->getName()) . " "
144-
. $this->getOrder()->formatPrice($attributes['price']);
154+
. $this->getOrder()->formatBasePrice($attributes['price']);
145155
}
146156
return $this->escapeHtml($item->getName());
147157
}
@@ -183,7 +193,10 @@ public function getChildren($item)
183193
}
184194

185195
/**
196+
* Check if price info can be shown
197+
*
186198
* @param mixed $item
199+
*
187200
* @return bool
188201
*/
189202
public function canShowPriceInfo($item)

app/code/Magento/CompareListGraphQl/Model/Service/Collection/GetComparableItemsCollection.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ public function execute(int $listId, ContextInterface $context): Collection
7878
$this->items->useProductItem()->setStoreId($context->getExtensionAttributes()->getStore()->getStoreId());
7979
$this->items->addAttributeToSelect(
8080
$this->catalogConfig->getProductAttributes()
81-
)->loadComparableAttributes()->addMinimalPrice()->addTaxPercents()->setVisibility(
82-
$this->catalogProductVisibility->getVisibleInSiteIds()
83-
);
81+
)->loadComparableAttributes()->addMinimalPrice()->addTaxPercents();
8482

8583
return $this->items;
8684
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Customer\ViewModel\Address;
8+
9+
use Magento\Directory\Model\RegionProvider as DirectoryRegionProvider;
10+
use Magento\Framework\View\Element\Block\ArgumentInterface;
11+
12+
class RegionProvider implements ArgumentInterface
13+
{
14+
15+
/**
16+
* @var DirectoryRegionProvider
17+
*/
18+
private $directoryRegionProvider;
19+
20+
/**
21+
* Constructor
22+
*
23+
* @param DirectoryRegionProvider $directoryRegionProvider
24+
*/
25+
public function __construct(
26+
DirectoryRegionProvider $directoryRegionProvider
27+
) {
28+
$this->directoryRegionProvider = $directoryRegionProvider;
29+
}
30+
31+
/**
32+
* Get region data json
33+
*
34+
* @return string
35+
*/
36+
public function getRegionJson(): string
37+
{
38+
return $this->directoryRegionProvider->getRegionJson();
39+
}
40+
}

app/code/Magento/Customer/view/frontend/layout/customer_account_create.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<block class="Magento\Customer\Block\Form\Register" name="customer_form_register" template="Magento_Customer::form/register.phtml">
1818
<arguments>
1919
<argument name="attribute_data" xsi:type="object">Magento\Customer\Block\DataProviders\AddressAttributeData</argument>
20+
<argument name="region_provider" xsi:type="object">Magento\Customer\ViewModel\Address\RegionProvider</argument>
2021
</arguments>
2122
<container name="form.additional.info" as="form_additional_info"/>
2223
<container name="customer.form.register.fields.before" as="form_fields_before" label="Form Fields Before" htmlTag="div" htmlClass="customer-form-before"/>

app/code/Magento/Customer/view/frontend/layout/customer_address_form.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<argument name="attribute_data" xsi:type="object">Magento\Customer\Block\DataProviders\AddressAttributeData</argument>
2323
<argument name="post_code_config" xsi:type="object">Magento\Customer\Block\DataProviders\PostCodesPatternsAttributeData</argument>
2424
<argument name="view_model" xsi:type="object">Magento\Customer\ViewModel\Address</argument>
25+
<argument name="region_provider" xsi:type="object">Magento\Customer\ViewModel\Address\RegionProvider</argument>
2526
</arguments>
2627
</block>
2728
</referenceContainer>

app/code/Magento/Customer/view/frontend/templates/address/edit.phtml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
/** @var \Magento\Customer\ViewModel\Address $viewModel */
99
/** @var \Magento\Framework\Escaper $escaper */
1010
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
11+
/** @var \Magento\Customer\ViewModel\Address\RegionProvider $regionProvider */
1112
$viewModel = $block->getViewModel();
13+
$regionProvider = $block->getRegionProvider();
1214
?>
1315
<?php $_company = $block->getLayout()->createBlock(\Magento\Customer\Block\Widget\Company::class) ?>
1416
<?php $_telephone = $block->getLayout()->createBlock(\Magento\Customer\Block\Widget\Telephone::class) ?>
@@ -222,13 +224,13 @@ $viewModel = $block->getViewModel();
222224
}
223225
},
224226
"#country": {
225-
"regionUpdater": {
227+
"directoryRegionUpdater": {
226228
"optionalRegionAllowed": <?= /* @noEscape */ $_displayAll ? 'true' : 'false' ?>,
227229
"regionListId": "#region_id",
228230
"regionInputId": "#region",
229231
"postcodeId": "#zip",
230232
"form": "#form-validate",
231-
"regionJson": <?= /* @noEscape */ $viewModel->dataGetRegionJson() ?>,
233+
"regionJson": <?= /* @noEscape */ $regionProvider->getRegionJson(); ?>,
232234
"defaultRegion": "<?= (int) $block->getRegionId() ?>",
233235
"countriesWithOptionalZip": <?= /* @noEscape */ $viewModel->dataGetCountriesWithOptionalZip(true) ?>
234236
}

app/code/Magento/Customer/view/frontend/templates/form/register.phtml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ use Magento\Customer\Helper\Address;
1414
$addressHelper = $block->getData('addressHelper');
1515
/** @var \Magento\Directory\Helper\Data $directoryHelper */
1616
$directoryHelper = $block->getData('directoryHelper');
17+
/** @var \Magento\Customer\ViewModel\Address\RegionProvider $regionProvider */
18+
$regionProvider = $block->getRegionProvider();
1719
$formData = $block->getFormData();
1820
?>
1921
<?php $displayAll = $block->getConfig('general/region/display_all'); ?>
@@ -342,22 +344,22 @@ script;
342344
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false) ?>
343345
<?php if ($block->getShowAddressFields()): ?>
344346
<?php
345-
$regionJson = /* @noEscape */ $directoryHelper->getRegionJson();
347+
$regionJson = /* @noEscape */ $regionProvider->getRegionJson();
346348
$regionId = (int) $formData->getRegionId();
347349
$countriesWithOptionalZip = /* @noEscape */ $directoryHelper->getCountriesWithOptionalZip(true);
348350
?>
349351
<script type="text/x-magento-init">
350352
{
351353
"#country": {
352-
"regionUpdater": {
354+
"directoryRegionUpdater": {
353355
"optionalRegionAllowed": <?= /* @noEscape */ $displayAll ? 'true' : 'false' ?>,
354356
"regionListId": "#region_id",
355357
"regionInputId": "#region",
356358
"postcodeId": "#zip",
357359
"form": "#form-validate",
358-
"regionJson": <?= $regionJson ?>,
359-
"defaultRegion": <?= $regionId ?>,
360-
"countriesWithOptionalZip": <?= $countriesWithOptionalZip ?>
360+
"regionJson": <?= /* @noEscape */ $regionJson ?>,
361+
"defaultRegion": <?= /* @noEscape */ $regionId ?>,
362+
"countriesWithOptionalZip": <?= /* @noEscape */ $countriesWithOptionalZip ?>
361363
}
362364
}
363365
}

app/code/Magento/Directory/Model/Currency.php

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\Locale\ResolverInterface as LocalResolverInterface;
1414
use Magento\Framework\NumberFormatterFactory;
1515
use Magento\Framework\Serialize\Serializer\Json;
16+
use Magento\Framework\Exception\LocalizedException;
1617

1718
/**
1819
* Currency model
@@ -39,8 +40,6 @@ class Currency extends \Magento\Framework\Model\AbstractModel
3940
protected $_filter;
4041

4142
/**
42-
* Currency Rates
43-
*
4443
* @var array
4544
*/
4645
protected $_rates;
@@ -147,11 +146,14 @@ public function __construct(
147146
$this->_localeCurrency = $localeCurrency;
148147
$this->currencyConfig = $currencyConfig ?: ObjectManager::getInstance()->get(CurrencyConfig::class);
149148
$this->localeResolver = $localeResolver ?: ObjectManager::getInstance()->get(LocalResolverInterface::class);
150-
$this->numberFormatterFactory = $numberFormatterFactory ?: ObjectManager::getInstance()->get(NumberFormatterFactory::class);
149+
$this->numberFormatterFactory = $numberFormatterFactory ?:
150+
ObjectManager::getInstance()->get(NumberFormatterFactory::class);
151151
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(Json::class);
152152
}
153153

154154
/**
155+
* Initializing Currency Resource model
156+
*
155157
* @return void
156158
*/
157159
protected function _construct()
@@ -253,10 +255,10 @@ public function getAnyRate($toCurrency)
253255
/**
254256
* Convert price to currency format
255257
*
256-
* @param float $price
257-
* @param mixed $toCurrency
258-
* @return float
259-
* @throws \Exception
258+
* @param float $price
259+
* @param mixed $toCurrency
260+
* @return float
261+
* @throws LocalizedException
260262
*/
261263
public function convert($price, $toCurrency = null)
262264
{
@@ -266,15 +268,18 @@ public function convert($price, $toCurrency = null)
266268
return (float)$price * (float)$rate;
267269
}
268270

269-
throw new \Exception(__(
271+
throw new LocalizedException(__(
270272
'Undefined rate from "%1-%2".',
271273
$this->getCode(),
272274
$this->getCurrencyCodeFromToCurrency($toCurrency)
273275
));
274276
}
275277

276278
/**
279+
* Return the currency code
280+
*
277281
* @param mixed $toCurrency
282+
*
278283
* @return string
279284
* @throws \Magento\Framework\Exception\InputException
280285
*/
@@ -348,8 +353,11 @@ public function formatPrecision(
348353
}
349354

350355
/**
356+
* Return formatted currency
357+
*
351358
* @param float $price
352359
* @param array $options
360+
*
353361
* @return string
354362
*/
355363
public function formatTxt($price, $options = [])
@@ -420,7 +428,8 @@ private function formatCurrency(string $price, array $options): string
420428
$this->numberFormatter = $this->getNumberFormatter($options);
421429

422430
$formattedCurrency = $this->numberFormatter->formatCurrency(
423-
$price, $this->getCode() ?? $this->numberFormatter->getTextAttribute(\NumberFormatter::CURRENCY_CODE)
431+
$price,
432+
$this->getCode() ?? $this->numberFormatter->getTextAttribute(\NumberFormatter::CURRENCY_CODE)
424433
);
425434

426435
if (array_key_exists(LocaleCurrency::CURRENCY_OPTION_SYMBOL, $options)) {
@@ -430,7 +439,7 @@ private function formatCurrency(string $price, array $options): string
430439

431440
if ((array_key_exists(LocaleCurrency::CURRENCY_OPTION_DISPLAY, $options)
432441
&& $options[LocaleCurrency::CURRENCY_OPTION_DISPLAY] === \Magento\Framework\Currency::NO_SYMBOL)) {
433-
$formattedCurrency = str_replace(' ', '', $formattedCurrency);
442+
$formattedCurrency = preg_replace(['/[^0-9.,۰٫]+/', '/ /'], '', $formattedCurrency);
434443
}
435444

436445
return preg_replace('/^\s+|\s+$/u', '', $formattedCurrency);
@@ -444,7 +453,10 @@ private function formatCurrency(string $price, array $options): string
444453
*/
445454
private function getNumberFormatter(array $options): \Magento\Framework\NumberFormatter
446455
{
447-
$key = 'currency_' . md5($this->localeResolver->getLocale() . $this->serializer->serialize($options));
456+
$key = 'currency_' . hash(
457+
'sha256',
458+
($this->localeResolver->getLocale() . $this->serializer->serialize($options))
459+
);
448460
if (!isset($this->numberFormatterCache[$key])) {
449461
$this->numberFormatter = $this->numberFormatterFactory->create(
450462
['locale' => $this->localeResolver->getLocale(), 'style' => \NumberFormatter::CURRENCY]
@@ -467,7 +479,8 @@ private function setOptions(array $options): void
467479
{
468480
if (array_key_exists(LocaleCurrency::CURRENCY_OPTION_SYMBOL, $options)) {
469481
$this->numberFormatter->setSymbol(
470-
\NumberFormatter::CURRENCY_SYMBOL, $options[LocaleCurrency::CURRENCY_OPTION_SYMBOL]
482+
\NumberFormatter::CURRENCY_SYMBOL,
483+
$options[LocaleCurrency::CURRENCY_OPTION_SYMBOL]
471484
);
472485
}
473486
if (array_key_exists(LocaleCurrency::CURRENCY_OPTION_DISPLAY, $options)
@@ -490,6 +503,8 @@ public function getCurrencySymbol()
490503
}
491504

492505
/**
506+
* Return the price format to be displayed to user
507+
*
493508
* @return string
494509
*/
495510
public function getOutputFormat()
@@ -532,6 +547,8 @@ public function getConfigDefaultCurrencies()
532547
}
533548

534549
/**
550+
* Retrieve base config currency data by config path.
551+
*
535552
* @return array
536553
*/
537554
public function getConfigBaseCurrencies()

0 commit comments

Comments
 (0)