Magento – How to create a your own dropdown for system configuration

Posted on Updated on

We can use our own system configurations in magento. Creating a drop down on our own manageable way of code will be benefited. Followings are the steps you could follow. This is only the way of magento. There are other methods too

1. Create your own module or use your existing module and Create a system configuration file
2. Add system configuration as follows

<sample_config_select translate=”label”>
<label>sample label</label>
<frontend_type>select</frontend_type>
<sort_order>1</sort_order>
<sort_order>100</sort_order>
<source_model>sample/select</source_model>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
<tooltip>adds select</tooltip>
</sample_config_select>

3. create options. we follow the way of magento structure or use your own.

class YourPackage_Module_Model_Sample
{

public function toOptionArray()
{
return array(
array(‘value’ => 0, ‘label’ => Mage::helper(‘adminhtml’)->__(‘select option 1’)),
array(‘value’ => 1, ‘label’ => Mage::helper(‘adminhtml’)->__(select option 2′)));
}

}

4. See the Configuration in Admin

Advertisements