From 5756780af0e1c6e0f3db3efe54a13620c9c93dbe Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz Date: Fri, 18 Dec 2020 23:54:12 +0100 Subject: [PATCH 001/322] Replace JSON serializer with JSON Hex Tag --- app/code/Magento/User/ViewModel/JsonSerializer.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/User/ViewModel/JsonSerializer.php b/app/code/Magento/User/ViewModel/JsonSerializer.php index 3cd234d9c41e2..26093a250656b 100644 --- a/app/code/Magento/User/ViewModel/JsonSerializer.php +++ b/app/code/Magento/User/ViewModel/JsonSerializer.php @@ -8,21 +8,19 @@ namespace Magento\User\ViewModel; -/** - * JsonSerializer - */ +use Magento\Framework\Serialize\Serializer\JsonHexTag; + class JsonSerializer implements \Magento\Framework\View\Element\Block\ArgumentInterface { - /** - * @var \Magento\Framework\Serialize\Serializer\Json + * @var JsonHexTag */ private $serializer; /** - * @param \Magento\Framework\Serialize\Serializer\Json $serializer + * @param JsonHexTag $serializer */ - public function __construct(\Magento\Framework\Serialize\Serializer\Json $serializer) + public function __construct(JsonHexTag $serializer) { $this->serializer = $serializer; } From e17db8be7b3e1d1a567367409cbe0322bc4469d7 Mon Sep 17 00:00:00 2001 From: Ihor Sviziev Date: Wed, 3 Mar 2021 14:58:36 +0200 Subject: [PATCH 002/322] Fix file upload styles duplication --- .../checkout/fields/_file-uploader.less | 597 +++++++++--------- 1 file changed, 299 insertions(+), 298 deletions(-) diff --git a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/fields/_file-uploader.less b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/fields/_file-uploader.less index fbd9701d44be9..f95d449aabcd2 100644 --- a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/fields/_file-uploader.less +++ b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/fields/_file-uploader.less @@ -61,389 +61,390 @@ // // Single file uploader // --------------------------------------------- +& when (@media-common = true) { + .file-uploader-area { + position: relative; -.file-uploader-area { - position: relative; - - input[type='file'] { - cursor: pointer; - opacity: 0; - overflow: hidden; - position: absolute; - visibility: hidden; - width: 0; + input[type='file'] { + cursor: pointer; + opacity: 0; + overflow: hidden; + position: absolute; + visibility: hidden; + width: 0; - &:focus { - + .file-uploader-button { - box-shadow: 0 0 0 1px @file-uploader-preview-focus__color; + &:focus { + + .file-uploader-button { + box-shadow: 0 0 0 1px @file-uploader-preview-focus__color; + } } - } - &:disabled { - + .file-uploader-button { - cursor: default; - opacity: .5; - pointer-events: none; + &:disabled { + + .file-uploader-button { + cursor: default; + opacity: .5; + pointer-events: none; + } } } } -} -.file-uploader-summary { - display: inline-block; - vertical-align: top; -} - -.file-uploader-button { - background: @color-gray-darken0; - border: 1px solid @color-gray_light; - box-sizing: border-box; - color: @color-black_dark; - cursor: pointer; - display: inline-block; - font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; - font-size: 1.4rem; - font-weight: 600; - line-height: 1.6rem; - margin: 0; - padding: 7px 15px; - vertical-align: middle; - - &._is-dragover { - background: @file-uploader-dragover__background; - border: 1px solid @file-uploader-preview-focus__color; + .file-uploader-summary { + display: inline-block; + vertical-align: top; } -} -.file-uploader-spinner { - background-image: url('@{baseDir}images/loader-1.gif'); - background-position: 50%; - background-repeat: no-repeat; - background-size: @file-uploader-spinner-dimensions; - display: none; - height: 30px; - margin-left: @indent__s; - vertical-align: top; - width: @file-uploader-spinner-dimensions; -} - -.file-uploader-preview { - .action-remove { - .lib-icon-font ( - @icon-delete__content, - @_icon-font: @icons__font-name, - @_icon-font-size: @file-uploader-delete-icon__font-size, - @_icon-font-color: @file-uploader-delete-icon__color, - @_icon-font-color-hover: @file-uploader-delete-icon__hover__color, - @_icon-font-text-hide: true, - @_icon-font-display: block - ); - bottom: 4px; + .file-uploader-button { + background: @color-gray-darken0; + border: 1px solid @color-gray_light; + box-sizing: border-box; + color: @color-black_dark; cursor: pointer; - display: block; - height: 27px; - left: 6px; - padding: 2px; - position: absolute; - text-decoration: none; - width: 25px; - z-index: 2; - } + display: inline-block; + font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; + font-size: 1.4rem; + font-weight: 600; + line-height: 1.6rem; + margin: 0; + padding: 7px 15px; + vertical-align: middle; - &:hover { - .preview-image img, - .preview-link:before { - opacity: @file-uploader-preview__opacity; + &._is-dragover { + background: @file-uploader-dragover__background; + border: 1px solid @file-uploader-preview-focus__color; } } - .preview-link { - display: block; - height: 100%; + .file-uploader-spinner { + background-image: url('@{baseDir}images/loader-1.gif'); + background-position: 50%; + background-repeat: no-repeat; + background-size: @file-uploader-spinner-dimensions; + display: none; + height: 30px; + margin-left: @indent__s; + vertical-align: top; + width: @file-uploader-spinner-dimensions; } - .preview-image img { - bottom: 0; - left: 0; - margin: auto; - max-height: 100%; - max-width: 100%; - position: absolute; - right: 0; - top: 0; - z-index: 1; - } + .file-uploader-preview { + .action-remove { + .lib-icon-font ( + @icon-delete__content, + @_icon-font: @icons__font-name, + @_icon-font-size: @file-uploader-delete-icon__font-size, + @_icon-font-color: @file-uploader-delete-icon__color, + @_icon-font-color-hover: @file-uploader-delete-icon__hover__color, + @_icon-font-text-hide: true, + @_icon-font-display: block + ); + bottom: 4px; + cursor: pointer; + display: block; + height: 27px; + left: 6px; + padding: 2px; + position: absolute; + text-decoration: none; + width: 25px; + z-index: 2; + } - .preview-video { - .lib-icon-font( - @icon-file__content, - @_icon-font: @icons__font-name, - @_icon-font-size: @file-uploader-video-icon__size, - @_icon-font-color: @file-uploader-video-icon__color, - @_icon-font-color-hover: @file-uploader-video-icon__color - ); + &:hover { + .preview-image img, + .preview-link:before { + opacity: @file-uploader-preview__opacity; + } + } - &:before { + .preview-link { + display: block; + height: 100%; + } + + .preview-image img { + bottom: 0; left: 0; - margin-top: -@file-uploader-video-icon__size / 2; + margin: auto; + max-height: 100%; + max-width: 100%; position: absolute; right: 0; - top: 50%; - z-index: @file-uploader-video-icon__z-index; + top: 0; + z-index: 1; } - } - .preview-document { - .lib-icon-font( + .preview-video { + .lib-icon-font( @icon-file__content, - @_icon-font: @icons__font-name, - @_icon-font-size: @file-uploader-document-icon__size, - @_icon-font-color: @file-uploader-document-icon__color, - @_icon-font-color-hover: @file-uploader-document-icon__color - ); + @_icon-font: @icons__font-name, + @_icon-font-size: @file-uploader-video-icon__size, + @_icon-font-color: @file-uploader-video-icon__color, + @_icon-font-color-hover: @file-uploader-video-icon__color + ); - &:before { - left: 0; - margin-top: -@file-uploader-document-icon__size / 2; - position: absolute; - right: 0; - top: 50%; - z-index: @file-uploader-document-icon__z-index; + &:before { + left: 0; + margin-top: -@file-uploader-video-icon__size / 2; + position: absolute; + right: 0; + top: 50%; + z-index: @file-uploader-video-icon__z-index; + } } - } -} -.file-uploader-preview, -.file-uploader-placeholder { - background: @file-uploader-preview__background-color; - border: 1px solid @file-uploader-preview__border-color; - box-sizing: border-box; - cursor: pointer; - display: block; - height: @file-uploader-preview__height; - line-height: 1; - margin: @indent__s @indent__m @indent__s 0; - overflow: hidden; - position: relative; - width: @file-uploader-preview__width; -} + .preview-document { + .lib-icon-font( + @icon-file__content, + @_icon-font: @icons__font-name, + @_icon-font-size: @file-uploader-document-icon__size, + @_icon-font-color: @file-uploader-document-icon__color, + @_icon-font-color-hover: @file-uploader-document-icon__color + ); -.file-uploader { - &._loading { - .file-uploader-spinner { - display: inline-block; + &:before { + left: 0; + margin-top: -@file-uploader-document-icon__size / 2; + position: absolute; + right: 0; + top: 50%; + z-index: @file-uploader-document-icon__z-index; + } } } - .admin__field-note, - .admin__field-error { - margin-bottom: @indent__s; + .file-uploader-preview, + .file-uploader-placeholder { + background: @file-uploader-preview__background-color; + border: 1px solid @file-uploader-preview__border-color; + box-sizing: border-box; + cursor: pointer; + display: block; + height: @file-uploader-preview__height; + line-height: 1; + margin: @indent__s @indent__m @indent__s 0; + overflow: hidden; + position: relative; + width: @file-uploader-preview__width; } - .file-uploader-filename { - .lib-text-overflow(); - max-width: @file-uploader-preview__width; - word-break: break-all; + .file-uploader { + &._loading { + .file-uploader-spinner { + display: inline-block; + } + } - &:first-child { + .admin__field-note, + .admin__field-error { margin-bottom: @indent__s; } - } - .file-uploader-meta { - color: @file-uploader-muted-text__color; - } + .file-uploader-filename { + .lib-text-overflow(); + max-width: @file-uploader-preview__width; + word-break: break-all; - .admin__field-fallback-reset { - margin-left: @indent__s; - } + &:first-child { + margin-bottom: @indent__s; + } + } - ._keyfocus & .action-remove { - &:focus { - box-shadow: 0 0 0 1px @file-uploader-preview-focus__color; + .file-uploader-meta { + color: @file-uploader-muted-text__color; } - } -} -// Placeholder for multiple uploader -.file-uploader-placeholder { - &.placeholder-document { - .lib-icon-font( - @icon-file__content, - @_icon-font: @icons__font-name, - @_icon-font-size: 5rem, - @_icon-font-color: @file-uploader-placeholder-icon__color, - @_icon-font-color-hover: @file-uploader-placeholder-icon__color - ); + .admin__field-fallback-reset { + margin-left: @indent__s; + } - &:before { - left: 0; - position: absolute; - right: 0; - top: 20px; - z-index: @file-uploader-placeholder-icon__z-index; + ._keyfocus & .action-remove { + &:focus { + box-shadow: 0 0 0 1px @file-uploader-preview-focus__color; + } } } - &.placeholder-image { - .lib-icon-font( + // Placeholder for multiple uploader + .file-uploader-placeholder { + &.placeholder-document { + .lib-icon-font( @icon-file__content, - @_icon-font: @icons__font-name, - @_icon-font-size: 5rem, - @_icon-font-color: @file-uploader-placeholder-icon__color, - @_icon-font-color-hover: @file-uploader-placeholder-icon__color - ); + @_icon-font: @icons__font-name, + @_icon-font-size: 5rem, + @_icon-font-color: @file-uploader-placeholder-icon__color, + @_icon-font-color-hover: @file-uploader-placeholder-icon__color + ); - &:before { - left: 0; - position: absolute; - right: 0; - top: 20px; - z-index: @file-uploader-placeholder-icon__z-index; + &:before { + left: 0; + position: absolute; + right: 0; + top: 20px; + z-index: @file-uploader-placeholder-icon__z-index; + } } - } - &.placeholder-video { - .lib-icon-font( + &.placeholder-image { + .lib-icon-font( @icon-file__content, - @_icon-font: @icons__font-name, - @_icon-font-size: 3rem, - @_icon-font-color: @file-uploader-placeholder-icon__color, - @_icon-font-color-hover: @file-uploader-placeholder-icon__color - ); + @_icon-font: @icons__font-name, + @_icon-font-size: 5rem, + @_icon-font-color: @file-uploader-placeholder-icon__color, + @_icon-font-color-hover: @file-uploader-placeholder-icon__color + ); - &:before { - left: 0; - position: absolute; - right: 0; - top: 30px; - z-index: @file-uploader-placeholder-icon__z-index; + &:before { + left: 0; + position: absolute; + right: 0; + top: 20px; + z-index: @file-uploader-placeholder-icon__z-index; + } } - } -} - -.file-uploader-placeholder-text { - bottom: 0; - color: @color-blue-dodger; - font-size: 1.1rem; - left: 0; - line-height: @line-height__base; - margin-bottom: 15%; - padding: 0 @indent__base; - position: absolute; - right: 0; - text-align: center; -} - -// -// Grid image uploader -// --------------------------------------------- - -.data-grid-file-uploader { - min-width: @data-grid-file-uploader-wrapper__size; - &._loading { - .file-uploader-spinner { - display: block; - } + &.placeholder-video { + .lib-icon-font( + @icon-file__content, + @_icon-font: @icons__font-name, + @_icon-font-size: 3rem, + @_icon-font-color: @file-uploader-placeholder-icon__color, + @_icon-font-color-hover: @file-uploader-placeholder-icon__color + ); - .file-uploader-button { &:before { - display: none; + left: 0; + position: absolute; + right: 0; + top: 30px; + z-index: @file-uploader-placeholder-icon__z-index; } } } - .file-uploader-image { - background: transparent; + .file-uploader-placeholder-text { bottom: 0; + color: @color-blue-dodger; + font-size: 1.1rem; left: 0; - margin: auto; - max-height: 100%; - max-width: 100%; + line-height: @line-height__base; + margin-bottom: 15%; + padding: 0 @indent__base; position: absolute; right: 0; - top: 0; - z-index: @data-grid-file-uploader-image__z-index; + text-align: center; + } + + // + // Grid image uploader + // --------------------------------------------- + + .data-grid-file-uploader { + min-width: @data-grid-file-uploader-wrapper__size; + + &._loading { + .file-uploader-spinner { + display: block; + } - + .file-uploader-area { .file-uploader-button { &:before { display: none; } } } - } - .file-uploader-area { - z-index: @data-grid-file-uploader-image__z-index + 1; - } + .file-uploader-image { + background: transparent; + bottom: 0; + left: 0; + margin: auto; + max-height: 100%; + max-width: 100%; + position: absolute; + right: 0; + top: 0; + z-index: @data-grid-file-uploader-image__z-index; + + + .file-uploader-area { + .file-uploader-button { + &:before { + display: none; + } + } + } + } - .file-uploader-spinner { - height: 100%; - margin: 0; - position: absolute; - top: 0; - width: 100%; - } + .file-uploader-area { + z-index: @data-grid-file-uploader-image__z-index + 1; + } - .file-uploader-button { - display: block; - height: @data-grid-file-uploader-upload-icon__line-height; - text-align: center; + .file-uploader-spinner { + height: 100%; + margin: 0; + position: absolute; + top: 0; + width: 100%; + } - .lib-icon-font ( + .file-uploader-button { + display: block; + height: @data-grid-file-uploader-upload-icon__line-height; + text-align: center; + + .lib-icon-font ( @icon-file__content, - @_icon-font: @icons__font-name, - @_icon-font-size: 1.3rem, - @_icon-font-line-height: @data-grid-file-uploader-upload-icon__line-height, - @_icon-font-color: @data-grid-file-uploader-upload-icon__color, - @_icon-font-color-hover: @data-grid-file-uploader-upload-icon__hover__color, - @_icon-font-text-hide: true, - @_icon-font-display: block - ); - } + @_icon-font: @icons__font-name, + @_icon-font-size: 1.3rem, + @_icon-font-line-height: @data-grid-file-uploader-upload-icon__line-height, + @_icon-font-color: @data-grid-file-uploader-upload-icon__color, + @_icon-font-color-hover: @data-grid-file-uploader-upload-icon__hover__color, + @_icon-font-text-hide: true, + @_icon-font-display: block + ); + } - .action-select-wrap { - float: left; + .action-select-wrap { + float: left; - .action-select { - border: 1px solid @file-uploader-preview__border-color; - display: block; - height: @data-grid-file-uploader-image__size; - margin-left: -1px; - padding: 0; - width: @data-grid-file-uploader-menu-button__width; - - &:after { - border-color: @data-grid-file-uploader-upload-icon__color transparent transparent transparent; - left: 50%; - margin: 0 0 0 -5px; - } + .action-select { + border: 1px solid @file-uploader-preview__border-color; + display: block; + height: @data-grid-file-uploader-image__size; + margin-left: -1px; + padding: 0; + width: @data-grid-file-uploader-menu-button__width; - &:hover { &:after { - border-color: @data-grid-file-uploader-upload-icon__hover__color transparent transparent transparent; + border-color: @data-grid-file-uploader-upload-icon__color transparent transparent transparent; + left: 50%; + margin: 0 0 0 -5px; + } + + &:hover { + &:after { + border-color: @data-grid-file-uploader-upload-icon__hover__color transparent transparent transparent; + } } - } - > span { - display: none; + > span { + display: none; + } } - } - .action-menu { - left: 4rem; - right: auto; - z-index: @data-grid-file-uploader-image__z-index + 1; + .action-menu { + left: 4rem; + right: auto; + z-index: @data-grid-file-uploader-image__z-index + 1; + } } } -} -.data-grid-file-uploader-inner { - border: 1px solid @file-uploader-preview__border-color; - float: left; - height: @data-grid-file-uploader-image__size; - position: relative; - width: @data-grid-file-uploader-image__size; + .data-grid-file-uploader-inner { + border: 1px solid @file-uploader-preview__border-color; + float: left; + height: @data-grid-file-uploader-image__size; + position: relative; + width: @data-grid-file-uploader-image__size; + } } From c8a02d2f37a179700699ba9336faba3019f9d557 Mon Sep 17 00:00:00 2001 From: Ioan Ulecan Date: Thu, 23 Dec 2021 08:27:46 +0200 Subject: [PATCH 003/322] Add Cart Rule product subselect condition --- .../SalesRule/Model/Rule/Condition/Product/Subselect.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php b/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php index 55479dc2f3e46..d3a0efb6de570 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php +++ b/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php @@ -68,7 +68,13 @@ public function asXml($containerKey = 'conditions', $itemKey = 'condition') */ public function loadAttributeOptions() { - $this->setAttributeOption(['qty' => __('total quantity'), 'base_row_total' => __('total amount')]); + $this->setAttributeOption( + [ + 'qty' => __('total quantity'), + 'base_row_total' => __('total amount (excl. tax)'), + 'row_total_incl_tax' => __('total amount (incl. tax)') + ] + ); return $this; } From 474fc91c394b12adcf30a439a7ea931a808b87fb Mon Sep 17 00:00:00 2001 From: Ioan Ulecan Date: Thu, 23 Dec 2021 11:12:39 +0200 Subject: [PATCH 004/322] i18n --- app/code/Magento/SalesRule/i18n/en_US.csv | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/SalesRule/i18n/en_US.csv b/app/code/Magento/SalesRule/i18n/en_US.csv index d4f93c25dc46c..fbeb283346676 100644 --- a/app/code/Magento/SalesRule/i18n/en_US.csv +++ b/app/code/Magento/SalesRule/i18n/en_US.csv @@ -99,7 +99,8 @@ FOUND,FOUND "NOT FOUND","NOT FOUND" "If an item is %1 in the cart with %2 of these conditions true:","If an item is %1 in the cart with %2 of these conditions true:" "total quantity","total quantity" -"total amount","total amount" +"total amount (excl. tax)","total amount (excl. tax)" +"total amount (incl. tax)","total amount (incl. tax)" is,is "is not","is not" "equals or greater than","equals or greater than" From e24c2b6e312b9fcfa89894d5ace0fc69401fbba9 Mon Sep 17 00:00:00 2001 From: Ioan Ulecan Date: Tue, 4 Jan 2022 18:12:02 +0200 Subject: [PATCH 005/322] Use base_row_total_incl_tax for total amount incl tax option --- .../SalesRule/Model/Rule/Condition/Product/Subselect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php b/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php index d3a0efb6de570..fcd7d75f372d3 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php +++ b/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php @@ -72,7 +72,7 @@ public function loadAttributeOptions() [ 'qty' => __('total quantity'), 'base_row_total' => __('total amount (excl. tax)'), - 'row_total_incl_tax' => __('total amount (incl. tax)') + 'base_row_total_incl_tax' => __('total amount (incl. tax)') ] ); return $this; From 957eec38b86d8d0645b5231e99814a4064b8996f Mon Sep 17 00:00:00 2001 From: monteshot Date: Wed, 24 Aug 2022 12:15:16 +0300 Subject: [PATCH 006/322] magento/magento2#35952 Admin Users unable to change front-end Logo in Design Config when in Single Store Mode - Fixed issue with logo in single store mode for Theme viewmodel - Fixed issue with logo in single store mode for Sales viewmodel --- .../ViewModel/Header/LogoPathResolverTest.php | 166 ++++++++++++++++++ .../ViewModel/Header/LogoPathResolver.php | 8 +- .../Html/Header/LogoPathResolverTest.php | 108 ++++++++++++ .../Block/Html/Header/LogoPathResolver.php | 6 +- 4 files changed, 285 insertions(+), 3 deletions(-) create mode 100644 app/code/Magento/Sales/Test/Unit/ViewModel/Header/LogoPathResolverTest.php create mode 100644 app/code/Magento/Theme/Test/Unit/ViewModel/Block/Html/Header/LogoPathResolverTest.php diff --git a/app/code/Magento/Sales/Test/Unit/ViewModel/Header/LogoPathResolverTest.php b/app/code/Magento/Sales/Test/Unit/ViewModel/Header/LogoPathResolverTest.php new file mode 100644 index 0000000000000..1d432275ab9a1 --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/ViewModel/Header/LogoPathResolverTest.php @@ -0,0 +1,166 @@ +scopeConfig->method('getValue') + ->withConsecutive( + ['general/single_store_mode/enabled', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null], + ['sales/identity/logo_html', ScopeInterface::SCOPE_WEBSITE, 1] + ) + ->willReturn( + "1", + 'sales_identity_logo_html_value' + ); + $valueForAssert = $this->model->getPath(); + $this->assertEquals('sales/store/logo_html/sales_identity_logo_html_value', $valueForAssert); + $this->assertNotNull($valueForAssert); + } + + /** + * Test for case when app in single store mode + * and logo path is not defined in config + * and header logo path is defined in config + * @return void + */ + public function testGetPathWhenInSingleStoreModeAndSalesLogoPathIsNullAndHeaderLogoPathIsNotNull(): void + { + $this->scopeConfig->method('getValue') + ->withConsecutive( + ['general/single_store_mode/enabled', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null], + ['sales/identity/logo_html', ScopeInterface::SCOPE_WEBSITE, 1], + ['design/header/logo_src', ScopeInterface::SCOPE_WEBSITE, 1] + ) + ->willReturn('1', null, 'SingleStore.png'); + $valueForAssert = $this->model->getPath(); + $this->assertEquals('logo/SingleStore.png', $valueForAssert); + $this->assertNotNull($valueForAssert); + } + + /** + * Test for case when app in single store mode + * and logo path is not defined in config + * and header logo path is not defined in config + * @return void + */ + public function testGetPathWhenInSingleStoreModeAndSalesLogoPathIsNullAndHeaderLogoPathIsNull(): void + { + $this->scopeConfig->method('getValue') + ->withConsecutive( + ['general/single_store_mode/enabled', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null], + ['sales/identity/logo_html', ScopeInterface::SCOPE_WEBSITE, 1], + ['design/header/logo_src', ScopeInterface::SCOPE_WEBSITE, 1] + ) + ->willReturn('1', null, null); + $valueForAssert = $this->model->getPath(); + $this->assertNull($valueForAssert); + } + + /** + * Test for case when app in multi store mode + * and logo path is defined in config + * @return void + */ + public function testGetPathWhenInMultiStoreModeAndPathNotNull(): void + { + $this->scopeConfig->method('getValue') + ->withConsecutive( + ['general/single_store_mode/enabled', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null], + ['sales/identity/logo_html', ScopeInterface::SCOPE_STORE, 1] + ) + ->willReturn('0', 'sales_identity_logo_html_value'); + $valueForAssert = $this->model->getPath(); + $this->assertEquals('sales/store/logo_html/sales_identity_logo_html_value', $valueForAssert); + $this->assertNotNull($valueForAssert); + } + + /** + * Test for case when app in single store mode + * and logo path is not defined in config + * and header logo path is not defined in config + * @return void + */ + public function testGetPathWhenInMultiStoreModeAndSalesLogoPathIsNullAndHeaderLogoPathIsNull(): void + { + $this->scopeConfig->method('getValue') + ->withConsecutive( + ['general/single_store_mode/enabled', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null], + ['sales/identity/logo_html', ScopeInterface::SCOPE_STORE, 1], + ['design/header/logo_src', ScopeInterface::SCOPE_STORE, 1] + ) + ->willReturn('0', null, null); + $valueForAssert = $this->model->getPath(); + $this->assertNull($valueForAssert); + } + + /** + * Test for case when app in single store mode + * and logo path is not defined in config + * and header logo path is defined in config + * @return void + */ + public function testGetPathWhenInMultiStoreModeAndSalesLogoPathIsNullAndHeaderLogoPathIsNotNull(): void + { + $this->scopeConfig->method('getValue') + ->withConsecutive( + ['general/single_store_mode/enabled', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null], + ['sales/identity/logo_html', ScopeInterface::SCOPE_WEBSITE, 1], + ['design/header/logo_src', ScopeInterface::SCOPE_WEBSITE, 1] + ) + ->willReturn('1', null, 'MultiStore.png'); + $valueForAssert = $this->model->getPath(); + $this->assertEquals('logo/MultiStore.png', $valueForAssert); + $this->assertNotNull($valueForAssert); + } + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + $this->scopeConfig = $this->createMock(ScopeConfigInterface::class); + $this->registry = $this->createMock(Registry::class); + $orderMock = $this->createMock(Order::class); + $orderMock->method('getStoreId') + ->willReturn(1); + $this->registry->method('registry') + ->with('current_order') + ->willReturn($orderMock); + $this->model = new LogoPathResolver($this->scopeConfig, $this->registry); + } +} diff --git a/app/code/Magento/Sales/ViewModel/Header/LogoPathResolver.php b/app/code/Magento/Sales/ViewModel/Header/LogoPathResolver.php index a640526517d47..d133388e4a4c1 100644 --- a/app/code/Magento/Sales/ViewModel/Header/LogoPathResolver.php +++ b/app/code/Magento/Sales/ViewModel/Header/LogoPathResolver.php @@ -54,9 +54,13 @@ public function getPath(): ?string if ($order instanceof Order) { $storeId = $order->getStoreId(); } + $scopeType = ScopeInterface::SCOPE_STORE; + if ($this->scopeConfig->getValue('general/single_store_mode/enabled') === "1") { + $scopeType = ScopeInterface::SCOPE_WEBSITE; + } $salesLogoPath = $this->scopeConfig->getValue( 'sales/identity/logo_html', - ScopeInterface::SCOPE_STORE, + $scopeType, $storeId ); @@ -66,7 +70,7 @@ public function getPath(): ?string $headerLogoPath = $this->scopeConfig->getValue( 'design/header/logo_src', - ScopeInterface::SCOPE_STORE, + $scopeType, $storeId ); diff --git a/app/code/Magento/Theme/Test/Unit/ViewModel/Block/Html/Header/LogoPathResolverTest.php b/app/code/Magento/Theme/Test/Unit/ViewModel/Block/Html/Header/LogoPathResolverTest.php new file mode 100644 index 0000000000000..3dd36a39a2abb --- /dev/null +++ b/app/code/Magento/Theme/Test/Unit/ViewModel/Block/Html/Header/LogoPathResolverTest.php @@ -0,0 +1,108 @@ +scopeConfig->method('getValue') + ->withConsecutive( + ['general/single_store_mode/enabled', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null], + ['design/header/logo_src', ScopeInterface::SCOPE_WEBSITE, null] + ) + ->willReturn('1', 'SingleStore.png'); + $valueForAssert = $this->model->getPath(); + $this->assertEquals('logo/SingleStore.png', $valueForAssert); + $this->assertNotNull($valueForAssert); + } + + /** + * Test for case when app in single store mode + * and logo path is not defined in config + * @return void + */ + public function testGetPathWhenInSingleStoreModeAndPathIsNull(): void + { + $this->scopeConfig->method('getValue') + ->withConsecutive( + ['general/single_store_mode/enabled', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null], + ['design/header/logo_src', ScopeInterface::SCOPE_WEBSITE, null] + ) + ->willReturn('1', null); + $this->assertNull($this->model->getPath()); + } + + /** + * Test for case when app in multi store mode + * and logo path is defined in config + * @return void + */ + public function testGetPathWhenInMultiStoreModeAndPathNotNull(): void + { + $this->scopeConfig->method('getValue') + ->withConsecutive( + ['general/single_store_mode/enabled', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null], + ['design/header/logo_src', ScopeInterface::SCOPE_STORE, null] + ) + ->willReturn('0', 'MultiStore.png'); + $valueForAssert = $this->model->getPath(); + $this->assertEquals('logo/MultiStore.png', $valueForAssert); + $this->assertNotNull($valueForAssert); + } + + /** + * Test for case when app in multi store mode + * and logo path is not defined in config + * @return void + */ + public function testGetPathWhenInMultiStoreModeAndPathIsNull(): void + { + $this->scopeConfig->method('getValue') + ->withConsecutive( + ['general/single_store_mode/enabled', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null], + ['design/header/logo_src', ScopeInterface::SCOPE_STORE, null] + ) + ->willReturn('0', null); + $this->assertNull($this->model->getPath()); + } + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + $this->scopeConfig = $this->createMock(ScopeConfigInterface::class); + $this->model = new LogoPathResolver($this->scopeConfig); + } +} diff --git a/app/code/Magento/Theme/ViewModel/Block/Html/Header/LogoPathResolver.php b/app/code/Magento/Theme/ViewModel/Block/Html/Header/LogoPathResolver.php index 1a10fe9177320..5be2cf9360ed4 100644 --- a/app/code/Magento/Theme/ViewModel/Block/Html/Header/LogoPathResolver.php +++ b/app/code/Magento/Theme/ViewModel/Block/Html/Header/LogoPathResolver.php @@ -39,9 +39,13 @@ public function __construct( public function getPath(): ?string { $path = null; + $scopeType = ScopeInterface::SCOPE_STORE; + if ($this->scopeConfig->getValue('general/single_store_mode/enabled') === "1") { + $scopeType = ScopeInterface::SCOPE_WEBSITE; + } $storeLogoPath = $this->scopeConfig->getValue( 'design/header/logo_src', - ScopeInterface::SCOPE_STORE + $scopeType ); if ($storeLogoPath !== null) { $path = Logo::UPLOAD_DIR . '/' . $storeLogoPath; From 047723a0c72e3793d5b387a8162ee157bdc1cd86 Mon Sep 17 00:00:00 2001 From: monteshot Date: Wed, 24 Aug 2022 14:04:04 +0300 Subject: [PATCH 007/322] magento/magento2#35952 Admin Users unable to change front-end Logo in Design Config when in Single Store Mode - Declared property for registry --- .../Test/Unit/ViewModel/Header/LogoPathResolverTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/code/Magento/Sales/Test/Unit/ViewModel/Header/LogoPathResolverTest.php b/app/code/Magento/Sales/Test/Unit/ViewModel/Header/LogoPathResolverTest.php index 1d432275ab9a1..1d95a6d39fedc 100644 --- a/app/code/Magento/Sales/Test/Unit/ViewModel/Header/LogoPathResolverTest.php +++ b/app/code/Magento/Sales/Test/Unit/ViewModel/Header/LogoPathResolverTest.php @@ -30,6 +30,11 @@ class LogoPathResolverTest extends TestCase */ private $model; + /** + * @var Registry|MockObject + */ + private $registry; + /** * Test for case when app in single store mode * and logo path is defined in config From 9b224ac45e6c7a5df924a0bc377064a0537a7044 Mon Sep 17 00:00:00 2001 From: Tu Nguyen Anh Date: Sun, 30 Oct 2022 12:25:11 +0700 Subject: [PATCH 008/322] Improve CLS avoid shift layout pdp screen --- .../frontend/layout/catalog_product_view.xml | 4 +-- .../templates/product/view/gallery.phtml | 7 ++++- .../web/css/source/_module.less | 14 --------- lib/web/css/source/lib/_breadcrumbs.less | 2 ++ .../source/lib/variables/_breadcrumbs.less | 1 + lib/web/mage/gallery/gallery.js | 31 +++++++------------ lib/web/mage/gallery/gallery.less | 4 +++ 7 files changed, 27 insertions(+), 36 deletions(-) diff --git a/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml b/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml index 6e24f84f00482..fb41f198c2350 100644 --- a/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml +++ b/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml @@ -36,7 +36,7 @@ - + @@ -111,7 +111,7 @@ - + gallery-prev-area diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/gallery.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/gallery.phtml index 4b33864aef47a..ce0fa3827afe0 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/gallery.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/gallery.phtml @@ -8,6 +8,7 @@ * Product media data template * * @var $block \Magento\Catalog\Block\Product\View\Gallery + * @var $escaper \Magento\Framework\Escaper */ ?> @@ -25,6 +26,8 @@ $helper = $block->getData('imageHelper'); $mainImageData = $mainImage ? $mainImage->getData('medium_image_url') : $helper->getDefaultPlaceholderUrl('image'); + $imageWidth = $block->getImageAttribute('product_page_image_medium', 'width'); + $imageHeight = $block->getImageAttribute('product_page_image_medium', 'height'); ?> @@ -33,9 +36,11 @@ $mainImageData = $mainImage ? alt="main product photo" class="gallery-placeholder__image" src="" + escapeHtmlAttr($imageWidth) .'"' : '' ?> + escapeHtmlAttr($imageHeight) .'"' : '' ?> /> - +