الأخبار التكنولوجية والاستعراضات والنصائح!

كيفية إضافة التحكم في عرض المتجر في نموذج المسؤول في Magento 2

ستساعدك المقالة التالية: كيفية إضافة التحكم في عرض المتجر في نموذج المسؤول في Magento 2

<؟ php

مساحة الاسم البائع \ ملحق \ بلوك \ مشرفهتمل \ أسئلة \ تحرير \ تبويب ؛

استخدم Magento \ Backend \ Block \ Store \ Switcher \ Form \ Renderer \ Fieldset \ Element ؛

استخدام Magento \ Backend \ Block \ Template \ Context ؛

استخدم Magento \ Backend \ Block \ Widget \ Form \ Generic ؛

استخدام Magento \ Framework \ Data \ FormFactory ؛

استخدام Magento \ Framework \ Registry ؛

استخدام Magento \ Store \ Model \ System \ Store ؛

تمتد أسئلة الفصل بشكل عام

{

محمية $ systemStore؛

الوظيفة العامة __construct (

تخزين $ systemStore ،

سياق $ سياق ،

التسجيل $ Registry ،

FormFactory $ formFactory ،

مجموعة بيانات $ = []

) {

الأصل :: __ الإنشاء ($ Context، $ Registry، $ formFactory، $ data)؛

$ this-> systemStore = $ systemStore ؛

}

وظيفة محمية _prepareForm ()

{

$ model = $ this -> _ coreRegistry-> Registry (‘row_data’) ؛

$ form = $ this -> _ formFactory-> create () ؛

مجموعة الحقول $ = نموذج دولار-> addFieldset (

“field_set_id” ،

[‘legend’ => __(‘form title’)]

) ؛

الحقل $ = مجموعة الحقول $-> addField (

“store_id” ،

‘يختار’،

[

                ‘label’ => __(‘Store View’),

                ‘title’ => __(‘Store View’),

                ‘name’ => ‘store_id’,

                ‘value’ => $model->getStoreId(),

                ‘values’ => $this->systemStore->getStoreValuesForForm(false, true)

//                set first argument true and second to false to add blank option which value is blank

//                set second argument true to add “All Store Views” option which value is 0

            ]

) ؛

Renderer = $ this-> getLayout () -> createBlock (

العنصر :: فئة

) ؛

$ field-> setRenderer ($ renderer) ؛

$ form-> setValues ​​($ model-> getData ()) ؛

$ this-> setForm (نموذج $) ؛

الوالد العائد :: _ PreparForm ()؛

}

}