0

I'm developing a module for Magento 2.3 and can't get default config values to show up in the admin. To the best of my knowledge, I've followed all the documentation I can find. It's kind of driving me crazy :)

A link to my full project can be found here: https://github.com/crankycyclops/DiscountCodeUrl

And here are the contents of the two relevant files:

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="promo">

            <group id="discounturl" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">

                <label>Discount URL Settings</label>

                <field id="enabled" translate="label comment" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Enabled</label>
                    <comment>If the discount URL module is enabled, you'll be able to apply discount codes automatically via URL. Disable this if you have other modules running that implement similar behavior or that might conflict.</comment>
                    <validate>required-entry</validate>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>

                <field id="url_param" translate="label comment" type="text" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>URL Parameter</label>
                    <comment>This is the GET parameter that will contain a coupon code in the URL. For example, if this value is "coupon", then https://store.url?coupon=CODE will set the coupon code to "CODE." If this value isn't set, we'll use the hardcoded default specified by Helper\Cookie::DEFAULT_URL_PARAMETER.</comment>
                </field>

                <field id="cookie_lifetime" translate="label comment" type="text" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Cookie Lifetime</label>
                    <comment>When a coupon code comes in through a URL, we set it in a cookie so that we can remember it for the entire session. This value determines how long that cookie should stay set before it expires (in seconds.) Value must be 0 or greater (0 means the cookie will remain alive until the browser window or tab remains open.) If this value isn't set, we'll use the hardcoded default specified by Helper\Cookie::COOKIE_LIFETIME.</comment>
                    <validate>validate-zero-or-greater</validate>
                </field>

            </group>

        </section>

    </system>

</config>

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>

        <promo>

            <discounturl>

                <enabled>0</enabled>
                <url_param>coupon</url_param>
                <cookie_lifetime>0</cookie_lifetime>

            </discounturl>

        </promo>

    </default>

</config>
8
  • I can see your config value in admin!
    – Pawan
    Commented Nov 24, 2019 at 10:12
  • That's weird. I can't, even after flushing my cache. Commented Nov 24, 2019 at 14:27
  • I download your module from git and and it showing correctly!
    – Pawan
    Commented Nov 24, 2019 at 14:29
  • which mode you are using ?
    – Pawan
    Commented Nov 24, 2019 at 14:29
  • @Pawan development mode. I'm on 2.3.3. Commented Nov 24, 2019 at 14:30

1 Answer 1

0

Looks like this is working for others and there's just something strange going on with my own instance of Magento.

2
  • just repliated for me when i just installed fresh version magetno 2.3.3 uing composer but after flushing cache after some time, issue fixed automatically, may be becuase of low server resources, Commented Jan 17, 2020 at 17:19
  • Interesting. Thanks for letting me know. Commented Jan 18, 2020 at 3:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.