Skip to content

Commit b948d35

Browse files
committed
AC-13054: Unable to see "Using Default value" message when changing the theme in design configuration page
Fix for static test failure & code optimised
1 parent da71cc7 commit b948d35

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

app/code/Magento/Backend/view/adminhtml/ui_component/design_config_listing.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2024 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">

app/code/Magento/Theme/Ui/Component/Design/Config/DataProvider.php

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Theme\Ui\Component\Design\Config;
77

@@ -96,40 +96,38 @@ public function getData()
9696
->create()
9797
);
9898
}
99+
100+
$themeConfigData = $this->getCoreConfigData();
99101
$data = parent::getData();
100102
foreach ($data['items'] as & $item) {
101103
$item += ['default' => __('Global')];
102104

103105
$scope = ($item['store_id']) ? 'stores' : (($item['store_website_id']) ? 'websites' : 'default');
104106
$scopeId = (int) $item['store_website_id'] ?? 0;
105107
$themeId = (int) $item['theme_theme_id'] ?? 0;
106-
$usingDefaultTheme = $this->isUsingDefaultTheme($scopeId, $themeId, $scope);
107-
$item += ['short_description' => $usingDefaultTheme ? __('Using Default Theme') : ''];
108+
109+
$criteria = ['scope' => $scope, 'scope_id' => $scopeId, 'value' => $themeId];
110+
$configData = array_filter($themeConfigData, function ($themeConfig) use ($criteria) {
111+
return array_intersect_assoc($criteria, $themeConfig) === $criteria;
112+
});
113+
114+
$item += ['short_description' => !$configData ? __('Using Default Theme') : ''];
108115
}
109116

110117
return $data;
111118
}
112119

113120
/**
114-
* Check if theme used is default theme
121+
* Get the core config data related to theme
115122
*
116-
* @param int $scopeId
117-
* @param int $themeId
118-
* @param string $scope
119-
* @return bool
123+
* @return array
120124
*/
121-
private function isUsingDefaultTheme(int $scopeId, int $themeId, string $scope): bool
125+
private function getCoreConfigData(): array
122126
{
123127
$connection = $this->resourceConnection->getConnection();
124-
$configId = $connection->fetchOne(
125-
$connection->select()->from(
126-
$connection->getTableName('core_config_data'),
127-
['config_id']
128-
)->where('value = ?', $themeId)
129-
->where('scope_id = ?', $scopeId)
130-
->where('path = ?', 'design/theme/theme_id')
131-
->where('scope = ?', $scope)
128+
return $connection->fetchAll(
129+
$connection->select()->from($connection->getTableName('core_config_data'))
130+
->where('path = ?', 'design/theme/theme_id')
132131
);
133-
return !$configId;
134132
}
135133
}

0 commit comments

Comments
 (0)