I am creating module that would display estimated delivery time.
I want to have a section in admin panel under "system"->"configuration" for my module that would contain seven input fields (one for each day of week), similar to this: enter image description here
The data should be stored in a database table.
I've tried searching for way to do this, but I couldn't find tutorials doing exactly this, and since i'm relatively new to Magento, I don't really know what needs to be changed.
1 Answer 1
To add custom section In system configuration, you have to create a Magento module, you can create by following below steps,
- Where
Vendor_Moduleis you module (Vendoris your company name andModuleis your module name, you can write whatever you want)
app/etc/modules/Vendor_Module.xml
<?xml version="1.0"?>
<config>
<modules>
<Vendor_Module>
<active>true</active>
<codePool>local</codePool>
</Vendor_Module>
</modules>
</config>
create a new directory in local(app>code>local) with Vendor and Module, so It should like this, and create a new config.xml
app/code/local/Vendor/Module/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Vendor_Module>
<version>1.0.0</version>
</Vendor_Module>
</modules>
<global>
<helpers>
<class>Vendor_Module_Helper</class>
</helpers>
</global>
</config>
now, create system.xml in etc directory, like this,
<?xml version="1.0"?>
<config>
<sections>
<shippinginfo translate="label" module="module">
<label>YOUR_LABEL</label>
<tab>general</tab>
<sort_order>60</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<shipping_times>
<fields>
<monday translate="label">
<label>Monday</label>
<frontend_type>text</frontend_type>
<comment>e.g 17.00</comment>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</monday>
<tuesday translate="label">
<label>Tuesday</label>
<frontend_type>text</frontend_type>
<comment>e.g 17.00</comment>
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</tuesday>
<wednesday translate="label">
<label>Wednesday</label>
<frontend_type>text</frontend_type>
<comment>e.g 17.00</comment>
<sort_order>30</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</wednesday>
<thursday translate="label">
<label>Thursday</label>
<frontend_type>text</frontend_type>
<comment>e.g 17.00</comment>
<sort_order>40</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</thursday>
<friday translate="label">
<label>Friday</label>
<frontend_type>text</frontend_type>
<comment>e.g 17.00</comment>
<sort_order>50</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</friday>
<saturday translate="label">
<label>Saturday</label>
<frontend_type>text</frontend_type>
<comment>Leave blank If its non shipping day</comment>
<sort_order>60</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</saturday>
<sunday translate="label">
<label>Sunday</label>
<frontend_type>text</frontend_type>
<comment>Leave blank If its non shipping day</comment>
<sort_order>70</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</sunday>
</fields>
</shipping_times>
</groups>
</shippinginfo>
</section>
</config>
now create a helper class in helper directory, like this
<?php
class Vendor_Module_Helper_Data extends Mage_Core_Helper_Abstract
{
}
refresh your cache, and check
And you don't need to save this value, Magento will manage this and you can get save value by using
Mage::getStoreConfig('shippinginfo/shipping_times/monday');
-
Hmmm, I did everything like you said, but I don't see the new section in the system->configurations. The module is working, I checked in the advanced settings. What could I be doing wrong?Metal Mathematician– Metal Mathematician2017年05月23日 10:27:23 +00:00Commented May 23, 2017 at 10:27
-
please refresh your cache, still If its not working then please post your full code here @JurģisTomsLiepiņšKeyur Shah– Keyur Shah2017年05月23日 13:10:19 +00:00Commented May 23, 2017 at 13:10
-
Sorry, I finally got back to trying this, but this does not seem to work. I copied all of the code as it is, didnt even change the module names. I refreshed my cache, but I still don't see "YOUR_LABEL" in the "general" tab. Can you suggest what might be wrong?Metal Mathematician– Metal Mathematician2017年06月08日 08:58:12 +00:00Commented Jun 8, 2017 at 8:58
System > Configurationthen you don't need to create table or write code. Magento will automatically save data ofSystem > Configurationfields tocore_config_datatable with its path.