3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+
7
+ declare (strict_types=1 );
8
+
6
9
namespace Magento \Store \Model \System ;
7
10
8
11
use Magento \Framework \Data \OptionSourceInterface ;
@@ -118,6 +121,7 @@ public function getStoreValuesForForm($empty = false, $all = false)
118
121
$ options [] = ['label ' => __ ('All Store Views ' ), 'value ' => 0 ];
119
122
}
120
123
124
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
121
125
$ nonEscapableNbspChar = html_entity_decode ('  ' , ENT_NOQUOTES , 'UTF-8 ' );
122
126
123
127
foreach ($ this ->_websiteCollection as $ website ) {
@@ -126,7 +130,7 @@ public function getStoreValuesForForm($empty = false, $all = false)
126
130
if ($ website ->getId () != $ group ->getWebsiteId ()) {
127
131
continue ;
128
132
}
129
- $ groupShow = false ;
133
+ $ values = [] ;
130
134
foreach ($ this ->_storeCollection as $ store ) {
131
135
if ($ group ->getId () != $ store ->getGroupId ()) {
132
136
continue ;
@@ -135,16 +139,12 @@ public function getStoreValuesForForm($empty = false, $all = false)
135
139
$ options [] = ['label ' => $ website ->getName (), 'value ' => []];
136
140
$ websiteShow = true ;
137
141
}
138
- if (!$ groupShow ) {
139
- $ groupShow = true ;
140
- $ values = [];
141
- }
142
142
$ values [] = [
143
143
'label ' => str_repeat ($ nonEscapableNbspChar , 4 ) . $ store ->getName (),
144
144
'value ' => $ store ->getId (),
145
145
];
146
146
}
147
- if ($ groupShow ) {
147
+ if (! empty ( $ values ) ) {
148
148
$ options [] = [
149
149
'label ' => str_repeat ($ nonEscapableNbspChar , 4 ) . $ group ->getName (),
150
150
'value ' => $ values ,
@@ -398,6 +398,7 @@ public function getStoreCollection()
398
398
399
399
/**
400
400
* Load/Reload collection(s) by type
401
+ *
401
402
* Allowed types: website, group, store or null for all
402
403
*
403
404
* @param string $type
0 commit comments