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>
-
I can see your config value in admin!Pawan– Pawan2019年11月24日 10:12:41 +00:00Commented Nov 24, 2019 at 10:12
-
That's weird. I can't, even after flushing my cache.Crankycyclops– Crankycyclops2019年11月24日 14:27:24 +00:00Commented Nov 24, 2019 at 14:27
-
I download your module from git and and it showing correctly!Pawan– Pawan2019年11月24日 14:29:25 +00:00Commented Nov 24, 2019 at 14:29
-
which mode you are using ?Pawan– Pawan2019年11月24日 14:29:43 +00:00Commented Nov 24, 2019 at 14:29
-
@Pawan development mode. I'm on 2.3.3.Crankycyclops– Crankycyclops2019年11月24日 14:30:27 +00:00Commented Nov 24, 2019 at 14:30
1 Answer 1
Looks like this is working for others and there's just something strange going on with my own instance of Magento.
-
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,sheraz khan– sheraz khan2020年01月17日 17:19:18 +00:00Commented Jan 17, 2020 at 17:19
-
Interesting. Thanks for letting me know.Crankycyclops– Crankycyclops2020年01月18日 03:05:01 +00:00Commented Jan 18, 2020 at 3:05
Explore related questions
See similar questions with these tags.