Configurazione I valori predefiniti non mostrano in Magento 2
-
13-12-2019 - |
Domanda
Ho impostato il nome del file predefinito in TextBox ma non funziona.Puoi per favore guidarmi dove sono andato storto?
Il mio codice è:
app / codice / apprendimento / personalizzato / etc / adminhtml / system.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Config/etc/system_file.xsd">
<system>
<tab id="custom" translate="label" sortOrder="0">
<label>Custom Extension</label>
</tab>
<section id="custom_customer" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Customer</label>
<tab>custom</tab>
<resource>Learning_Custom::config_custom</resource>
<group id="magento_customer_logs" translate="label" type="text" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Magento Customer Logs</label>
<field id="magento_request" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Magento Customer Request</label>
</field>
<field id="magento_response" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Magento Customer Response</label>
</field>
</group>
</section>
</system>
</config>
.
app / codice / apprendimento / personalizzato / etc / acl.xml
<?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">
<resource id="Learning_Custom::config_custom" title="Custom Section" sortOrder="80" />
</resource>
</resource>
</resource>
</resource>
</resources>
</acl>
</config>
.
app / codice / apprendimento / personalizzato / etc / config.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd">
<default>
<custom_customer>
<magento_customer_logs>
<magento_request>magento_request</magento_request>
<magento_response>magento_response</magento_response>
</magento_customer_logs>
</custom_customer>
</default>
</config>
.
Potresti per favore fammi sapere dove sono andato storto?
Soluzione
system.xml sembra
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd"> <system> <tab id="custom" translate="label" sortOrder="0"> <label>Custom Extension </tab> <section id="custom_customer" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Customer</label> <tab>custom</tab> <resource>Learning_Custom::config_custom</resource> <group id="magento_customer_logs" translate="label" type="text" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Magento Customer Logs</label> <field id="magento_request" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Magento Customer Request</label> </field> <field id="magento_response" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Magento Customer Response</label> </field> </group> </section> </system> </config>.
ACL.XML sembra
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn: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"> <resource id="Learning_Custom::config_custom" title="Custom Section" sortOrder="80" /> </resource> </resource> </resource> </resource> </resources> </acl> </config>.
config.xml sembra
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd"> <default> <custom_customer> <magento_customer_logs> <magento_request>magento_request</magento_request> <magento_response>magento_response</magento_response> </magento_customer_logs> </custom_customer> </default> </config>.
Provalo.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange