Magento2
varsayılan değeri aynı gibi ayarlamanıza izin verir Magento1
. İletişim modülüne baktığınızda Magento2
,
system.xml
kontak modülü için
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="contact" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Contacts</label>
<tab>general</tab>
<resource>Magento_Contact::contact</resource>
<group id="contact" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Contact Us</label>
<field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable Contact Us</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<backend_model>Magento\Contact\Model\System\Config\Backend\Links</backend_model>
</field>
</group>
<group id="email" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Email Options</label>
<field id="recipient_email" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Send Emails To</label>
<validate>validate-email</validate>
</field>
<field id="sender_email_identity" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Email Sender</label>
<source_model>Magento\Config\Model\Config\Source\Email\Identity</source_model>
</field>
<field id="email_template" translate="label comment" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Email Template</label>
<comment>Email template chosen based on theme fallback when "Default" option is selected.</comment>
<source_model>Magento\Config\Model\Config\Source\Email\Template</source_model>
</field>
</group>
</section>
</system>
</config>
ve config.xml
kontak modülü için
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<contact>
<enabled>1</enabled>
</contact>
<email>
<recipient_email>
<![CDATA[hello@example.com]]>
</recipient_email>
<sender_email_identity>custom2</sender_email_identity>
<email_template>contact_email_email_template</email_template>
</email>
</default>
</config>
Eğer varsayılan değeri ayarlamak istiyorsak, onun kimliğiyle aynı olması gerekir.
<section id="contact">
<group id="contact">
<field id="enabled">
sonra olur
<default>
<contact>
<enabled>1</enabled>
</contact>
</default>