Skip to content

cannot load template after renewed template id

I am trying to set up a custom email template, it was work but shows an error after the template id is changed. May I know any way to fix it? Thanks!

app/code/Myvendor/Mymodule/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>
    <tab id="custom_tabs" translate="label" sortOrder="110">
        <label>Email Tabs</label>
    </tab>
    <section id="email_section" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
        <label>Custom Email send</label>
        <tab>custom_tabs</tab>
        <resource>Cleargo_ProductEnquiry::config</resource>
        <group id="sendmail" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Email Setting</label>
            <field id="enabled" translate="label comment" type="select" sortOrder="10" showInDefault="1"
                   showInWebsite="1" showInStore="1">
                <label>Enabled</label>
                <source_model>MagentoConfigModelConfigSourceYesno</source_model>
                <comment><![CDATA[Your Comments]]></comment>
            </field>
            <field id="sender" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="3" canRestore="1">
                <label>Product failed email sender</label>
                <source_model>MagentoConfigModelConfigSourceEmailIdentity</source_model>
                <depends>
                    <field id="enabled">1</field>
                </depends>
            </field>
            <field id="email_template" translate="label comment" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
                <label>Custom Email Template</label>
                <comment>Email template chosen based on theme fallback when "Default" option is selected.</comment>
                <source_model>MagentoConfigModelConfigSourceEmailTemplate</source_model>
                <depends>
                    <field id="enabled">1</field>
                </depends>
            </field>
        </group>
    </section>

</system>

app/code/Myvendor/Mymodule/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>
    <email_section>
        <sendmail>
            <enabled>1</enabled>
            <sender>general</sender>
            <email_template>product_enquiry_email_template</email_template>
        </sendmail>
    </email_section>
</default>

app/code/Myvendor/Mymodule/etc/email_templates.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>
    <email_section>
        <sendmail>
            <enabled>1</enabled>
            <sender>general</sender>
            <email_template>product_enquiry_email_template</email_template>
        </sendmail>
    </email_section>
</default>

Then I got the below error:

Exception #0 (UnexpectedValueException): Email template 'email_section_sendmail_email_template' is not defined.