Skip to content

Commit 1e01381

Browse files
author
Stanislav Idolov
authored
Merge branch '2.4-develop' into ref-AdminAddBundleItemsTest
2 parents 6c9f5b5 + e88d5bd commit 1e01381

File tree

19 files changed

+665
-77
lines changed

19 files changed

+665
-77
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
}

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()

app/code/Magento/MediaGallerySynchronization/Model/CreateAssetFromFile.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function execute(string $path): AssetInterface
8282
* SPL file info is not compatible with remote storages and must not be used.
8383
*/
8484
$file = $this->getFileInfo->execute($absolutePath);
85-
[$width, $height] = getimagesize($absolutePath);
85+
[$width, $height] = getimagesizefromstring($absolutePath);
8686
$meta = [
8787
'size' => $file->getSize(),
8888
'extension' => $file->getExtension(),
@@ -98,12 +98,12 @@ public function execute(string $path): AssetInterface
9898
[
9999
'id' => null,
100100
'path' => $path,
101-
'title' => $meta['basename'],
102-
'width' => $meta['extra']['image-width'],
103-
'height' => $meta['extra']['image-height'],
101+
'title' => $meta['basename'] ?? '',
102+
'width' => $meta['extra']['image-width'] ?? 0,
103+
'height' => $meta['extra']['image-height'] ?? 0,
104104
'hash' => $this->getHash($path),
105-
'size' => $meta['size'],
106-
'contentType' => 'image/' . $meta['extension'],
105+
'size' => $meta['size'] ?? 0,
106+
'contentType' => sprintf('%s/%s', 'image', $meta['extension'] ?? ''),
107107
'source' => 'Local'
108108
]
109109
);

app/code/Magento/Sales/etc/config.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@
114114
<async_indexing>0</async_indexing>
115115
</grid>
116116
</dev>
117+
<system>
118+
<media_storage_configuration>
119+
<allowed_resources>
120+
<sales_logo_folder>sales/store/logo</sales_logo_folder>
121+
<sales_logo_html_folder>sales/store/logo_html</sales_logo_html_folder>
122+
</allowed_resources>
123+
</media_storage_configuration>
124+
</system>
117125
<customer>
118126
<create_account>
119127
<email_required_create_order>1</email_required_create_order>

app/code/Magento/Search/Model/ResourceModel/Query/Collection.php

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\Data\Collection\EntityFactoryInterface;
1010
use Magento\Framework\DB\Adapter\AdapterInterface;
1111
use Magento\Framework\DB\Helper;
12+
use Magento\Framework\DB\Select;
1213
use Magento\Framework\Event\ManagerInterface;
1314
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
1415
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
@@ -26,22 +27,16 @@
2627
class Collection extends AbstractCollection
2728
{
2829
/**
29-
* Store for filter
30-
*
3130
* @var int
3231
*/
3332
protected $_storeId;
3433

3534
/**
36-
* Store manager
37-
*
3835
* @var StoreManagerInterface
3936
*/
4037
protected $_storeManager;
4138

4239
/**
43-
* Search resource helper
44-
*
4540
* @var Helper
4641
*/
4742
protected $_resourceHelper;
@@ -116,21 +111,22 @@ public function getStoreId()
116111
*/
117112
public function setQueryFilter($query)
118113
{
119-
$this->getSelect()->reset(
120-
\Magento\Framework\DB\Select::FROM
121-
)->distinct(
122-
true
123-
)->from(
124-
['main_table' => $this->getTable('search_query')]
125-
)->where(
126-
'num_results > 0 AND display_in_terms = 1 AND query_text LIKE ?',
127-
$this->_resourceHelper->addLikeEscape($query, ['position' => 'start'])
128-
)->order(
129-
'popularity ' . \Magento\Framework\DB\Select::SQL_DESC
130-
);
114+
$this->getSelect()
115+
->reset(Select::FROM)
116+
->distinct(true)
117+
->from(['main_table' => $this->getTable('search_query')])
118+
->reset(Select::COLUMNS)
119+
->columns(['query_text', 'num_results', 'popularity'])
120+
->where(
121+
'num_results > 0 AND display_in_terms = 1 AND query_text LIKE ?',
122+
$this->_resourceHelper->addLikeEscape($query, ['position' => 'start'])
123+
)
124+
->order('popularity ' . \Magento\Framework\DB\Select::SQL_DESC);
125+
131126
if ($this->getStoreId()) {
132127
$this->getSelect()->where('store_id = ?', (int)$this->getStoreId());
133128
}
129+
134130
return $this;
135131
}
136132

dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementCustomAttributesTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ protected function verifyImageAttribute($customAttributeArray, $expectedFileName
186186
$this->assertStringContainsString($expectedFileName, $customAttribute[AttributeValue::VALUE]);
187187
$mediaDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::MEDIA);
188188
$customerMediaPath = $mediaDirectory->getAbsolutePath(CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER);
189-
$imageAttributeFound = file_exists($customerMediaPath . $customAttribute[AttributeValue::VALUE]);
189+
$imageAttributeFound = $mediaDirectory->getDriver()->isExists(
190+
$customerMediaPath . $customAttribute[AttributeValue::VALUE]
191+
);
190192
$this->assertTrue($imageAttributeFound, 'Expected file was not created');
191193
}
192194
}

0 commit comments

Comments
 (0)