Need help buying now? +48-22-219-5163 +1-917-720-3250
My Cart

Your Cart is Empty

Need help buying now?
+48-22-219-5163 +1-917-720-3250

Magento configuration system

Magento configuration system

Despite that Magento administrative panel is quite large and complicated the configuration system in it is very simple. Let’s start from the beginning and figure out why we need it at all.

Configuration system is a universal place where system variables are stored, including modules and plug-ins. It is for 100% sure that one day you will decide to modify some of your Magento extensions. And this will only be possible due to the configuration system, because it allows you not only read the files but modify them, as well. This makes the configuration system so required and appreciated by Magento users.

First of all, it is very important to know the order of the configuration files upload. They are usually loaded from the system cache. However, sometimes there is no cache, it is outdated or disabled. Then configuration files are created and placed in the root system directories:

{root_dir}/app/etc/config.xml
{root_dir}/app/etc/modules/*.xml
{root_dir}/app/etc/local.xml

 

When it is impossible to upload local.xml, the file {root_dir}/app/etc/distro.xml is uploaded instead. Then, you should upload the configuration files {module_dir}/etc/config.xml for all enabled (active == true) modules. Then the database configuration files are read: information about websites (core_website tables), information about stores (core_store table) and the main configuration (core_config_data table).

Let us review the changes in the admin panel using an example of UPS module in which we need to add ‘overprice’ parameter with default setting 7. This module adds $7 to each ordered product which corresponds to the shipping price of UPS company. In order to do this, we need to open the file shipping.xml and add the following code.

<config>
<default>
<carriers>
<ups>
<overprice>7</overprice>
</ups>
</carriers>
</default>
</config>

 

In order for this configuration to be displayed in the admin panel, we need to add the following code in file shipping.xml in Shipping methods – UPS section.

<config>
<sections>
<carriers>
<groups>
<ups>
<fields>
<overprice translate="label">
<label>Flat shipping fee for all parts/accessories purchases totaling less than minimum 
order amount for free shipping</label>
<frontend_type>text</frontend_type>
<sort_order>333</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</overprice>
</fields>
</ups>
</groups>
</carriers>
</sections>
</config>

 

In order for these changes to be displayed in the admin panel and applied on the site, we need to add the following code in app/Mage.php file:

public function getConfigData($field)
{
if (empty($this->_code)) {
return false;
}
$path = 'carriers/'.$this->_code.'/'.$field;
return Mage::getStoreConfig($path, $this->getStore());
}

 

The principle of work of this specific configuration is that, due to the settings in xml files, the system can read all information but show only some specific data to the customers, including the data written in configuration files by default. In this case, it is $7 shipping price of UPS company.

All configuration modifications are stored in core_config_data table. If you have any additional questions, please feel free to leave your comments or contact us directly, and our Magento experts will do their best to assist you.

Newsletter