2015-09-16 13 views

Odpowiedz

10

Tak, w Magento 2 można utworzyć plik konfiguracji systemu taki sam jak Magento 1.x. Ale będzie musiał utworzyć kilka innych plików.

Musisz użyć następującego pliku, aby go utworzyć.

1) app/code/Vendor/Helloworld/etc/adminhtml/system.xml 

2) app/code/Vendor/Helloworld/etc/acl.xml 

Te 2 pliki są ważne, aby utworzyć konfigurację systemu.

W system.xml plik

Dodawanie wspólna treść

<?xml version="1.0"?> 
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Config/etc/system_file.xsd"> 
    <system> 
     <!-- Add new Tab --> 
     <tab id="vendor" translate="label" sortOrder="300"> 
      <label>Vendor Extension</label> 
     </tab> 
     <section id="helloworld" translate="label" type="text" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="1"> 
      <label>Helloworld</label> 
      <tab>vendor</tab> 
      <!-- resource tag name which we have to defined in the acl.xml --> 
      <resource>Vendor_Helloworld::config_helloworld</resource> 
      <group id="general" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1"> 
       <label>General Options</label> 
       <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1"> 
        <label>Enabled</label> 
        <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> 
       </field> 
      </group> 
     </section> 
    </system> 
</config> 

W acl.xml plik

W pliku należy napisać poniższej zawartości

<?xml version="1.0"?> 
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> 
    <acl> 
     <resources> 
      <resource id="Magento_Backend::admin"> 
       <resource id="Magento_Backend::stores"> 
        <resource id="Magento_Backend::stores_settings"> 
         <resource id="Magento_Config::config"> 
          <!-- this resource id we can use in system.xml for section --> 
          <resource id="Vendor_Helloworld::config_helloworld" title="Helloworld Section" sortOrder="80" /> 
         </resource> 
        </resource> 
       </resource> 
      </resource> 
     </resources> 
    </acl> 
</config> 

Po tym okresie należy usunąć Pamięć podręczna magento & Wyloguj się ze strony administratora. Następnie Zaloguj się po stronie administratora. W sklepie> Konfiguracja widoczna jest zakładka "Rozszerzenie dostawcy". Po kliknięciu tego możesz zobaczyć szczegóły tego.

+0

Sprawdził się doskonale, gdy przeniosłem element "group" do elementu "section". Inaczej system.xml spowodował błąd. – Gerard

Powiązane problemy