22
22
use Magento \Eav \Model \Entity \Type ;
23
23
use Magento \Framework \App \ObjectManager ;
24
24
use Magento \Framework \App \RequestInterface ;
25
+ use Magento \Framework \Config \DataInterfaceFactory ;
25
26
use Magento \Framework \Exception \LocalizedException ;
26
27
use Magento \Framework \Exception \NoSuchEntityException ;
27
28
use Magento \Framework \Registry ;
@@ -153,6 +154,11 @@ class DataProvider extends ModifierPoolDataProvider
153
154
*/
154
155
private $ categoryFactory ;
155
156
157
+ /**
158
+ * @var DataInterfaceFactory
159
+ */
160
+ protected $ uiConfigFactory ;
161
+
156
162
/**
157
163
* @var ScopeOverriddenValue
158
164
*/
@@ -193,6 +199,7 @@ class DataProvider extends ModifierPoolDataProvider
193
199
* @param Config $eavConfig
194
200
* @param RequestInterface $request
195
201
* @param CategoryFactory $categoryFactory
202
+ * @param DataInterfaceFactory $uiConfigFactory
196
203
* @param array $meta
197
204
* @param array $data
198
205
* @param PoolInterface|null $pool
@@ -215,6 +222,7 @@ public function __construct(
215
222
Config $ eavConfig ,
216
223
RequestInterface $ request ,
217
224
CategoryFactory $ categoryFactory ,
225
+ DataInterfaceFactory $ uiConfigFactory ,
218
226
array $ meta = [],
219
227
array $ data = [],
220
228
PoolInterface $ pool = null ,
@@ -233,6 +241,7 @@ public function __construct(
233
241
$ this ->storeManager = $ storeManager ;
234
242
$ this ->request = $ request ;
235
243
$ this ->categoryFactory = $ categoryFactory ;
244
+ $ this ->uiConfigFactory = $ uiConfigFactory ;
236
245
$ this ->auth = $ auth ?? ObjectManager::getInstance ()->get (AuthorizationInterface::class);
237
246
$ this ->arrayUtils = $ arrayUtils ?? ObjectManager::getInstance ()->get (ArrayUtils::class);
238
247
$ this ->scopeOverriddenValue = $ scopeOverriddenValue ?:
@@ -645,56 +654,22 @@ public function getDefaultMetaData($result)
645
654
*/
646
655
protected function getFieldsMap ()
647
656
{
648
- return [
649
- 'general ' => [
650
- 'parent ' ,
651
- 'path ' ,
652
- 'is_active ' ,
653
- 'include_in_menu ' ,
654
- 'name ' ,
655
- ],
656
- 'content ' => [
657
- 'image ' ,
658
- 'description ' ,
659
- 'landing_page ' ,
660
- ],
661
- 'display_settings ' => [
662
- 'display_mode ' ,
663
- 'is_anchor ' ,
664
- 'available_sort_by ' ,
665
- 'use_config.available_sort_by ' ,
666
- 'default_sort_by ' ,
667
- 'use_config.default_sort_by ' ,
668
- 'filter_price_range ' ,
669
- 'use_config.filter_price_range ' ,
670
- ],
671
- 'search_engine_optimization ' => [
672
- 'url_key ' ,
673
- 'url_key_create_redirect ' ,
674
- 'url_key_group ' ,
675
- 'meta_title ' ,
676
- 'meta_keywords ' ,
677
- 'meta_description ' ,
678
- ],
679
- 'assign_products ' => [
680
- ],
681
- 'design ' => [
682
- 'custom_use_parent_settings ' ,
683
- 'custom_apply_to_products ' ,
684
- 'custom_design ' ,
685
- 'page_layout ' ,
686
- 'custom_layout_update ' ,
687
- 'custom_layout_update_file '
688
- ],
689
- 'schedule_design_update ' => [
690
- 'custom_design_from ' ,
691
- 'custom_design_to ' ,
692
- ],
693
- 'category_view_optimization ' => [
694
- ],
695
- 'category_permissions ' => [
696
- ],
697
- ];
657
+ $ referenceName = 'category_form ' ;
658
+ $ config = $ this ->uiConfigFactory
659
+ ->create (['componentName ' => $ referenceName ])
660
+ ->get ($ referenceName );
661
+
662
+ $ fieldsMap = [];
663
+
664
+ if (isset ($ config ['children ' ]) && !empty ($ config ['children ' ])) {
665
+ foreach ($ config ['children ' ] as $ name => $ child ) {
666
+ if (isset ($ child ['children ' ]) && !empty ($ child ['children ' ])) {
667
+ $ fieldsMap [$ name ] = array_keys ($ child ['children ' ]);
668
+ }
669
+ }
670
+ }
671
+
672
+ return $ fieldsMap ;
698
673
}
699
674
700
675
/**
0 commit comments