How to create dropdown/select box in magento system.xml for payment/shipping configuration

  • looks like self promotion and it is anyway a duplicate question Apr 26 '16 at 13:53
  • Too generic, please be more specific. Apr 26 '16 at 19:00
  • Please check below i also put the answer of my question. Apr 28 '16 at 7:07

Create drop down in system.xml and show custom values in it, rather than using default magento classes only

Directory : app/code/local/Companyname/Modulename/config/system.xml

In system.xml

  <Modulename translate="label" module="Modulename">
   <label>Payment Module</label>
   <paymentmethod translate="label comment">
       <label>Payment method</label>
       <comment>Omni Payment method.</comment>

If you want to create your custom source_Model, you need to do the following steps: Create a Pmethod.php in app/code/local/Companyname/Modulename/Model/Pmethod.php Companyname_Modulename is our module name. You need to create a function name toOptionArray() as mention below, the value and label can be anything you want to be display in dropdown

In Pmethod.php

class Companyname_Modulename_Model_Pmethod
    public function toOptionArray()
        return array(
                'value' => 'key1',
                'label' => 'Label 1',
                'value' => 'key2',
                'label' => 'label 2',
  • How to show selected value in backend dropdown? Because after saving it's not showing selected value in dropdpwn. Jun 23 '17 at 6:45
  • You need to check <source_model>Modulename/Modelname</source_model> with same value as Model Jun 24 '17 at 9:17
  • Yes that's correct in mine, Values are fetched properly but after saving it's not showing selected value in dropdown. Jun 25 '17 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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