Skip to content

Commit da71cc7

Browse files
committed
AC-13054: Unable to see "Using Default value" message when changing the theme in design configuration page
Added short description in grid to denote if using default theme
1 parent 0b488dd commit da71cc7

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,10 @@
1616
<label translate="true">Theme Name</label>
1717
</settings>
1818
</column>
19+
<column name="short_description" sortOrder="45">
20+
<settings>
21+
<label translate="true">Short Description</label>
22+
</settings>
23+
</column>
1924
</columns>
2025
</listing>

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\Api\Search\ReportingInterface;
1010
use Magento\Framework\Api\Search\SearchCriteriaBuilder;
1111
use Magento\Framework\App\RequestInterface;
12+
use Magento\Framework\App\ResourceConnection;
1213
use Magento\Store\Model\StoreManagerInterface;
1314

1415
/**
@@ -25,6 +26,11 @@ class DataProvider extends \Magento\Framework\View\Element\UiComponent\DataProvi
2526
*/
2627
protected $storeManager;
2728

29+
/**
30+
* @var ResourceConnection
31+
*/
32+
private $resourceConnection;
33+
2834
/**
2935
* @param string $name
3036
* @param string $primaryFieldName
@@ -34,6 +40,7 @@ class DataProvider extends \Magento\Framework\View\Element\UiComponent\DataProvi
3440
* @param RequestInterface $request
3541
* @param FilterBuilder $filterBuilder
3642
* @param StoreManagerInterface $storeManager
43+
* @param ResourceConnection $resourceConnection
3744
* @param array $meta
3845
* @param array $data
3946
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -47,6 +54,7 @@ public function __construct(
4754
RequestInterface $request,
4855
FilterBuilder $filterBuilder,
4956
StoreManagerInterface $storeManager,
57+
ResourceConnection $resourceConnection,
5058
array $meta = [],
5159
array $data = []
5260
) {
@@ -62,6 +70,7 @@ public function __construct(
6270
$data
6371
);
6472
$this->storeManager = $storeManager;
73+
$this->resourceConnection = $resourceConnection;
6574
}
6675

6776
/**
@@ -90,8 +99,37 @@ public function getData()
9099
$data = parent::getData();
91100
foreach ($data['items'] as & $item) {
92101
$item += ['default' => __('Global')];
102+
103+
$scope = ($item['store_id']) ? 'stores' : (($item['store_website_id']) ? 'websites' : 'default');
104+
$scopeId = (int) $item['store_website_id'] ?? 0;
105+
$themeId = (int) $item['theme_theme_id'] ?? 0;
106+
$usingDefaultTheme = $this->isUsingDefaultTheme($scopeId, $themeId, $scope);
107+
$item += ['short_description' => $usingDefaultTheme ? __('Using Default Theme') : ''];
93108
}
94109

95110
return $data;
96111
}
112+
113+
/**
114+
* Check if theme used is default theme
115+
*
116+
* @param int $scopeId
117+
* @param int $themeId
118+
* @param string $scope
119+
* @return bool
120+
*/
121+
private function isUsingDefaultTheme(int $scopeId, int $themeId, string $scope): bool
122+
{
123+
$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)
132+
);
133+
return !$configId;
134+
}
97135
}

app/code/Magento/Theme/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,4 @@ ID,ID
193193
View,View
194194
Action,Action
195195
"Display Report Bugs Link","Display Report Bugs Link"
196+
"Using Default Theme","Using Default Theme"

0 commit comments

Comments
 (0)