Как установить значение по умолчанию для поля конфигурации с типом время
Как я могу установить значение по умолчанию для поля из system.xml с типом времени?
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="my_checkout" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Checkout</label>
<tab>my_tab</tab>
<resource>My_Checkout::config</resource>
<group id="cut_off_time" translate="label" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Delivery Cut-off Time</label>
<field id="cut_off_time_start" type="time" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Start Time</label>
</field>
</group>
</section>
</system>
Для поля "cut_off_time_start" с типом ВРЕМЯ.
4
2 answers
Попробуйте этот формат:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<my_checkout>
<cut_off_time>
<cut_off_time_start>02,00,00</cut_off_time_start>
</cut_off_time>
</my_checkout>
</default>
</config>
2
Author: Siarhey Uchukhlebau, 2018-10-09 10:24:16
Шаг 1: создайте файл в этом расположении для создания полей конфигурации –
App/code///etc/adminhtml/system.xml
<?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>
<section id="payment">
<group id="wkmodule" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[Test Payment Module]]></label>
<field id="active" translate="label" type="select" sortOrder="101" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
</group>
</section>
Шаг 2: Создайте файл для установки значений по умолчанию здесь:
App/code///etc/config.xml
<?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>
<payment>
<wkmodule>
<active>0</active>
<------>x</---->
</wkmodule>
</payment>
</default>
Для получения дополнительной информации Нажмите здесь
0
Author: Chirag Patel, 2018-10-09 08:52:31