2

I want to set default values with a model from declared class in system.xml.

The result of the model is extracted from the database, from a custom table and the result looks like this: AF,AL,DE,BE,FR ...

How can I set to a model in specificcountry from etc/config.xml file?

On the Magento2 default is:

<?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>
        <carriers>
            <mailpostenonetwodays>
                <model>Vendorname\Modulename\Model\Carrier</model>
                <active>1</active>
                <title>Courier</title>
                <name>Shipping Method name</name>
                <price>5.00</price>
                <specificerrmsg>This shipping method is not available. To use this shipping method, please contact us.</specificerrmsg>
                <sallowspecific>1</sallowspecific>
                <specificcountry>AF,AL,DE,BE,FR</specificcountry>
            </mailpostenonetwodays>
        </carriers>
    </default>
</config>

I want to use like this:

<?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>
        <carriers>
            <mailpostenonetwodays>
                <model>Vendorname\Modulename\Model\Carrier</model>
                <active>1</active>
                <title>Courier</title>
                <name>Shipping Method name</name>
                <price>5.00</price>
                <specificerrmsg>This shipping method is not available. To use this shipping method, please contact us.</specificerrmsg>
                <sallowspecific>1</sallowspecific>
                <specificcountry>
                    <source_model>Vendornmae\Modulename\Model\Test</source_model>
                </specificcountry>
            </mailpostenonetwodays>
        </carriers>
    </default>
</config>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.