diff --git a/app/code/Magento/Backup/Test/Mftf/Test/AdminCreateAndDeleteBackupsTest.xml b/app/code/Magento/Backup/Test/Mftf/Test/AdminCreateAndDeleteBackupsTest.xml index 7319069c94589..31d0a3a22db51 100644 --- a/app/code/Magento/Backup/Test/Mftf/Test/AdminCreateAndDeleteBackupsTest.xml +++ b/app/code/Magento/Backup/Test/Mftf/Test/AdminCreateAndDeleteBackupsTest.xml @@ -17,6 +17,9 @@ + + Magento backup functionality is deprecated + diff --git a/app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/View/Items/Renderer.php b/app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/View/Items/Renderer.php index dee924ae3cf5e..480395767326b 100644 --- a/app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/View/Items/Renderer.php +++ b/app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/View/Items/Renderer.php @@ -19,8 +19,6 @@ class Renderer extends \Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer { /** - * Serializer - * * @var Json */ private $serializer; @@ -211,7 +209,7 @@ public function getValueHtml($item) if (!$this->isChildCalculated($item)) { $attributes = $this->getSelectionAttributes($item); if ($attributes) { - $result .= " " . $this->getItem()->getOrder()->formatPrice($attributes['price']); + $result .= " " . $this->getItem()->getOrder()->formatBasePrice($attributes['price']); } } return $result; diff --git a/app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php b/app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php index 003ddba86ad75..3ae422065f8eb 100644 --- a/app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php +++ b/app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php @@ -16,8 +16,6 @@ class Renderer extends \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer { /** - * Serializer - * * @var Json */ private $serializer; @@ -43,7 +41,10 @@ public function __construct( } /** + * Check if shipment type (invoice etc) is separate + * * @param mixed $item + * * @return bool * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ @@ -79,7 +80,10 @@ public function isShipmentSeparately($item = null) } /** + * Check if sub product calculations are present + * * @param mixed $item + * * @return bool * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ @@ -117,7 +121,10 @@ public function isChildCalculated($item = null) } /** + * Get bundle selection attributes + * * @param mixed $item + * * @return mixed|null */ public function getSelectionAttributes($item) @@ -134,14 +141,17 @@ public function getSelectionAttributes($item) } /** + * Get html of bundle selection attributes + * * @param mixed $item + * * @return string */ public function getValueHtml($item) { if ($attributes = $this->getSelectionAttributes($item)) { return sprintf('%d', $attributes['qty']) . ' x ' . $this->escapeHtml($item->getName()) . " " - . $this->getOrder()->formatPrice($attributes['price']); + . $this->getOrder()->formatBasePrice($attributes['price']); } return $this->escapeHtml($item->getName()); } @@ -183,7 +193,10 @@ public function getChildren($item) } /** + * Check if price info can be shown + * * @param mixed $item + * * @return bool */ public function canShowPriceInfo($item) diff --git a/app/code/Magento/CompareListGraphQl/Model/Service/Collection/GetComparableItemsCollection.php b/app/code/Magento/CompareListGraphQl/Model/Service/Collection/GetComparableItemsCollection.php index e766ec85248a1..083f527948911 100644 --- a/app/code/Magento/CompareListGraphQl/Model/Service/Collection/GetComparableItemsCollection.php +++ b/app/code/Magento/CompareListGraphQl/Model/Service/Collection/GetComparableItemsCollection.php @@ -78,9 +78,7 @@ public function execute(int $listId, ContextInterface $context): Collection $this->items->useProductItem()->setStoreId($context->getExtensionAttributes()->getStore()->getStoreId()); $this->items->addAttributeToSelect( $this->catalogConfig->getProductAttributes() - )->loadComparableAttributes()->addMinimalPrice()->addTaxPercents()->setVisibility( - $this->catalogProductVisibility->getVisibleInSiteIds() - ); + )->loadComparableAttributes()->addMinimalPrice()->addTaxPercents(); return $this->items; } diff --git a/app/code/Magento/Directory/Model/Currency.php b/app/code/Magento/Directory/Model/Currency.php index 65b47d7535cb2..e1815b2561978 100644 --- a/app/code/Magento/Directory/Model/Currency.php +++ b/app/code/Magento/Directory/Model/Currency.php @@ -13,6 +13,7 @@ use Magento\Framework\Locale\ResolverInterface as LocalResolverInterface; use Magento\Framework\NumberFormatterFactory; use Magento\Framework\Serialize\Serializer\Json; +use Magento\Framework\Exception\LocalizedException; /** * Currency model @@ -39,8 +40,6 @@ class Currency extends \Magento\Framework\Model\AbstractModel protected $_filter; /** - * Currency Rates - * * @var array */ protected $_rates; @@ -147,11 +146,14 @@ public function __construct( $this->_localeCurrency = $localeCurrency; $this->currencyConfig = $currencyConfig ?: ObjectManager::getInstance()->get(CurrencyConfig::class); $this->localeResolver = $localeResolver ?: ObjectManager::getInstance()->get(LocalResolverInterface::class); - $this->numberFormatterFactory = $numberFormatterFactory ?: ObjectManager::getInstance()->get(NumberFormatterFactory::class); + $this->numberFormatterFactory = $numberFormatterFactory ?: + ObjectManager::getInstance()->get(NumberFormatterFactory::class); $this->serializer = $serializer ?: ObjectManager::getInstance()->get(Json::class); } /** + * Initializing Currency Resource model + * * @return void */ protected function _construct() @@ -253,10 +255,10 @@ public function getAnyRate($toCurrency) /** * Convert price to currency format * - * @param float $price - * @param mixed $toCurrency - * @return float - * @throws \Exception + * @param float $price + * @param mixed $toCurrency + * @return float + * @throws LocalizedException */ public function convert($price, $toCurrency = null) { @@ -266,7 +268,7 @@ public function convert($price, $toCurrency = null) return (float)$price * (float)$rate; } - throw new \Exception(__( + throw new LocalizedException(__( 'Undefined rate from "%1-%2".', $this->getCode(), $this->getCurrencyCodeFromToCurrency($toCurrency) @@ -274,7 +276,10 @@ public function convert($price, $toCurrency = null) } /** + * Return the currency code + * * @param mixed $toCurrency + * * @return string * @throws \Magento\Framework\Exception\InputException */ @@ -348,8 +353,11 @@ public function formatPrecision( } /** + * Return formatted currency + * * @param float $price * @param array $options + * * @return string */ public function formatTxt($price, $options = []) @@ -420,7 +428,8 @@ private function formatCurrency(string $price, array $options): string $this->numberFormatter = $this->getNumberFormatter($options); $formattedCurrency = $this->numberFormatter->formatCurrency( - $price, $this->getCode() ?? $this->numberFormatter->getTextAttribute(\NumberFormatter::CURRENCY_CODE) + $price, + $this->getCode() ?? $this->numberFormatter->getTextAttribute(\NumberFormatter::CURRENCY_CODE) ); if (array_key_exists(LocaleCurrency::CURRENCY_OPTION_SYMBOL, $options)) { @@ -430,7 +439,7 @@ private function formatCurrency(string $price, array $options): string if ((array_key_exists(LocaleCurrency::CURRENCY_OPTION_DISPLAY, $options) && $options[LocaleCurrency::CURRENCY_OPTION_DISPLAY] === \Magento\Framework\Currency::NO_SYMBOL)) { - $formattedCurrency = str_replace(' ', '', $formattedCurrency); + $formattedCurrency = preg_replace(['/[^0-9.,۰٫]+/', '/ /'], '', $formattedCurrency); } return preg_replace('/^\s+|\s+$/u', '', $formattedCurrency); @@ -444,7 +453,10 @@ private function formatCurrency(string $price, array $options): string */ private function getNumberFormatter(array $options): \Magento\Framework\NumberFormatter { - $key = 'currency_' . md5($this->localeResolver->getLocale() . $this->serializer->serialize($options)); + $key = 'currency_' . hash( + 'sha256', + ($this->localeResolver->getLocale() . $this->serializer->serialize($options)) + ); if (!isset($this->numberFormatterCache[$key])) { $this->numberFormatter = $this->numberFormatterFactory->create( ['locale' => $this->localeResolver->getLocale(), 'style' => \NumberFormatter::CURRENCY] @@ -467,7 +479,8 @@ private function setOptions(array $options): void { if (array_key_exists(LocaleCurrency::CURRENCY_OPTION_SYMBOL, $options)) { $this->numberFormatter->setSymbol( - \NumberFormatter::CURRENCY_SYMBOL, $options[LocaleCurrency::CURRENCY_OPTION_SYMBOL] + \NumberFormatter::CURRENCY_SYMBOL, + $options[LocaleCurrency::CURRENCY_OPTION_SYMBOL] ); } if (array_key_exists(LocaleCurrency::CURRENCY_OPTION_DISPLAY, $options) @@ -490,6 +503,8 @@ public function getCurrencySymbol() } /** + * Return the price format to be displayed to user + * * @return string */ public function getOutputFormat() @@ -532,6 +547,8 @@ public function getConfigDefaultCurrencies() } /** + * Retrieve base config currency data by config path. + * * @return array */ public function getConfigBaseCurrencies() diff --git a/app/code/Magento/MediaGallerySynchronization/Model/CreateAssetFromFile.php b/app/code/Magento/MediaGallerySynchronization/Model/CreateAssetFromFile.php index 19c2569695d56..96a74db83b8c8 100644 --- a/app/code/Magento/MediaGallerySynchronization/Model/CreateAssetFromFile.php +++ b/app/code/Magento/MediaGallerySynchronization/Model/CreateAssetFromFile.php @@ -82,7 +82,7 @@ public function execute(string $path): AssetInterface * SPL file info is not compatible with remote storages and must not be used. */ $file = $this->getFileInfo->execute($absolutePath); - [$width, $height] = getimagesize($absolutePath); + [$width, $height] = getimagesizefromstring($absolutePath); $meta = [ 'size' => $file->getSize(), 'extension' => $file->getExtension(), @@ -98,12 +98,12 @@ public function execute(string $path): AssetInterface [ 'id' => null, 'path' => $path, - 'title' => $meta['basename'], - 'width' => $meta['extra']['image-width'], - 'height' => $meta['extra']['image-height'], + 'title' => $meta['basename'] ?? '', + 'width' => $meta['extra']['image-width'] ?? 0, + 'height' => $meta['extra']['image-height'] ?? 0, 'hash' => $this->getHash($path), - 'size' => $meta['size'], - 'contentType' => 'image/' . $meta['extension'], + 'size' => $meta['size'] ?? 0, + 'contentType' => sprintf('%s/%s', 'image', $meta['extension'] ?? ''), 'source' => 'Local' ] ); diff --git a/app/code/Magento/Sales/etc/config.xml b/app/code/Magento/Sales/etc/config.xml index 5127735a329d6..92e1a46bb2d5d 100644 --- a/app/code/Magento/Sales/etc/config.xml +++ b/app/code/Magento/Sales/etc/config.xml @@ -114,6 +114,14 @@ 0 + + + + sales/store/logo + sales/store/logo_html + + + 1 diff --git a/app/code/Magento/Search/Model/ResourceModel/Query/Collection.php b/app/code/Magento/Search/Model/ResourceModel/Query/Collection.php index 8d3db36e35dec..e122f61ff1b29 100644 --- a/app/code/Magento/Search/Model/ResourceModel/Query/Collection.php +++ b/app/code/Magento/Search/Model/ResourceModel/Query/Collection.php @@ -9,6 +9,7 @@ use Magento\Framework\Data\Collection\EntityFactoryInterface; use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\DB\Helper; +use Magento\Framework\DB\Select; use Magento\Framework\Event\ManagerInterface; use Magento\Framework\Model\ResourceModel\Db\AbstractDb; use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; @@ -26,22 +27,16 @@ class Collection extends AbstractCollection { /** - * Store for filter - * * @var int */ protected $_storeId; /** - * Store manager - * * @var StoreManagerInterface */ protected $_storeManager; /** - * Search resource helper - * * @var Helper */ protected $_resourceHelper; @@ -116,21 +111,22 @@ public function getStoreId() */ public function setQueryFilter($query) { - $this->getSelect()->reset( - \Magento\Framework\DB\Select::FROM - )->distinct( - true - )->from( - ['main_table' => $this->getTable('search_query')] - )->where( - 'num_results > 0 AND display_in_terms = 1 AND query_text LIKE ?', - $this->_resourceHelper->addLikeEscape($query, ['position' => 'start']) - )->order( - 'popularity ' . \Magento\Framework\DB\Select::SQL_DESC - ); + $this->getSelect() + ->reset(Select::FROM) + ->distinct(true) + ->from(['main_table' => $this->getTable('search_query')]) + ->reset(Select::COLUMNS) + ->columns(['query_text', 'num_results', 'popularity']) + ->where( + 'num_results > 0 AND display_in_terms = 1 AND query_text LIKE ?', + $this->_resourceHelper->addLikeEscape($query, ['position' => 'start']) + ) + ->order('popularity ' . \Magento\Framework\DB\Select::SQL_DESC); + if ($this->getStoreId()) { $this->getSelect()->where('store_id = ?', (int)$this->getStoreId()); } + return $this; } diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php index 5caaf9742aed2..bd78b151197f5 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php @@ -42,8 +42,6 @@ class ProductTest extends \PHPUnit\Framework\TestCase private $productRepository; /** - * Stock item attributes which must be exported - * * @var array */ public static $stockItemAttributes = [ @@ -132,7 +130,9 @@ public function testExportWithJsonAndMarkupTextAttribute(string $attributeData, $attribute = $eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'text_attribute'); $attribute->setDefaultValue($attributeData); /** @var \Magento\Catalog\Api\ProductAttributeRepositoryInterface $productAttributeRepository */ - $productAttributeRepository = $objectManager->get(\Magento\Catalog\Api\ProductAttributeRepositoryInterface::class); + $productAttributeRepository = $objectManager->get( + \Magento\Catalog\Api\ProductAttributeRepositoryInterface::class + ); $productAttributeRepository->save($attribute); $product->setCustomAttribute('text_attribute', $attribute->getDefaultValue()); $productRepository->save($product); @@ -154,14 +154,14 @@ public function exportWithJsonAndMarkupTextAttributeDataProvider(): array { return [ 'json' => [ - '{"type": "basic", "unit": "inch", "sign": "(\")", "size": "1.5\""}', - '"text_attribute={""type"": ""basic"", ""unit"": ""inch"", ""sign"": ""(\"")"", ""size"": ""1.5\""""}"' + '{"type": "basic", "unit": "inch", "sign": "(")", "size": "1.5""}', + '"text_attribute={""type"": ""basic"", ""unit"": ""inch"", ""sign"": ""("")"", ""size"": ""1.5""""}"' ], 'markup' => [ '
Element type is basic, measured in inches ' . - '(marked with sign (\")) with size 1.5\", mid-price range
', + '(marked with sign (")) with size 1.5", mid-price range', '"text_attribute=
Element type is basic, measured in inches ' . - '(marked with sign (\"")) with size 1.5\"", mid-price range
"' + '(marked with sign ("")) with size 1.5"", mid-price range"' ], ]; } @@ -607,7 +607,7 @@ public function testExportProductWithTwoWebsites(): void $productAction->updateWebsites([$productId], [$secondStore->getWebsiteId()], 'add'); $product->setStoreId($secondStore->getId()); $product->setPrice('9.99'); - $product->getResource()->save($product); + $this->productRepository->save($product); $exportData = $this->model->export();