- The
Magento\Backend\Block\Page\Header
class is used for the backend template (admin theme). It should not be used for the frontend theme.
- If you need to override the
logo.phtml
file, you don't need to redeclare the layout instructors for the logo block in the default.xml
file. Instead, you can directly copy that file from the Magento_Theme
module (located at vendor/magento/module-theme/view/frontend/templates/html/header/logo.phtml
) to <your_theme_dir>/Magento_Theme/templates/header/
directory in your theme and make the necessary modifications there.
For example, if your theme is called Magetu/winter
and it is located in the app/design
directory, the logo.phtml
file in your theme will have the following file path: app/design/Magetu/winter/Magento_Theme/templates/header/logo.phtml
.
You can read more about Override a layout at https://developer.adobe.com/commerce/frontend-core/guide/layouts/override/
- Remember to clean the Page Cache cache type (
full_page
) after uploading the logo to ensure that the changes take effect.
Regarding the issue of changing the header logo in the admin doesn't reflect on the frontend, there is a related issue in recent Magento versions, including version 2.4.6.
https://github.com/magento/magento2/issues/35952
This issue has been resolved and merged into the 2.4-develop
branch of the Magento repository through pull request #36008 at https://github.com/magento/magento2/pull/36008/.
I created a custom composer patch file (diff
file) for Magento and Adobe Commerce version 2.4.5 and higher, using that pull request:
diff --git a/vendor/magento/module-sales/ViewModel/Header/LogoPathResolver.php b/vendor/magento/module-sales/ViewModel/Header/LogoPathResolver.php
index a640526517d47..d133388e4a4c1 100644
--- a/vendor/magento/module-sales/ViewModel/Header/LogoPathResolver.php
+++ b/vendor/magento/module-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/vendor/magento/module-theme/ViewModel/Block/Html/Header/LogoPathResolver.php b/vendor/magento/module-theme/ViewModel/Block/Html/Header/LogoPathResolver.php
index 1a10fe9177320..5be2cf9360ed4 100644
--- a/vendor/magento/module-theme/ViewModel/Block/Html/Header/LogoPathResolver.php
+++ b/vendor/magento/module-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;
To apply this custom composer patch, I suggest using the Vaimo Composer Patches plugin https://github.com/vaimo/composer-patches. This plugin can apply the patch to multiple files within a diff
file.
Alternatively, if you prefer to use the Cweagans Composer Patches plugin https://github.com/cweagans/composer-patches, you can refer to the official Adobe Commerce documentation at https://experienceleague.adobe.com/docs/commerce-operations/upgrade-guide/patches/apply.html?lang=en#composer
As the Cweagans Composer Patches plugin does not support applying the patch to multiple files within a diff
file, you'll need to create 2 separate diff
files:
- The patch file for the
magento/module-theme
module's composer package:
diff --git a/vendor/magento/module-theme/ViewModel/Block/Html/Header/LogoPathResolver.php b/vendor/magento/module-theme/ViewModel/Block/Html/Header/LogoPathResolver.php
index 1a10fe9177320..5be2cf9360ed4 100644
--- a/vendor/magento/module-theme/ViewModel/Block/Html/Header/LogoPathResolver.php
+++ b/vendor/magento/module-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;
- The patch file for the
magento/module-sales
module's composer package:
diff --git a/vendor/magento/module-sales/ViewModel/Header/LogoPathResolver.php b/vendor/magento/module-sales/ViewModel/Header/LogoPathResolver.php
index a640526517d47..d133388e4a4c1 100644
--- a/vendor/magento/module-sales/ViewModel/Header/LogoPathResolver.php
+++ b/vendor/magento/module-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
);