Payment Methods – Load All in System Config for Magento 1.14

admin-panelmagento-1.14payment-methodssystem-config

I want to load all available payment methods in a multiselect system config in admin. Could some one help?

Best Answer

In system.xml

,

<test translate="label">
      <label>Available Payments</label>
      <frontend_type>select</frontend_type>
      <source_model>module_name/system_config_source_payment</source_model>
      <sort_order>5</sort_order>
      <show_in_default>1</show_in_default>
      <show_in_website>1</show_in_website>
      <show_in_store>1</show_in_store>
</test>

In Namespace/Modulename/Model/System/Config/Source/Payment.php

class Namespace_Modulename_Model_System_Config_Source_Payment
{
        public function toOptionArray()
        {
           $payments = Mage::getSingleton('payment/config')->getActiveMethods();

           //$methods = array(array('value'=>'', 'label'=>Mage::helper('adminhtml')->__('--Please Select--')));

           foreach ($payments as $paymentCode=>$paymentModel) {
                $paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
                $methods[$paymentCode] = array(
                    'label'   => $paymentTitle,
                    'value' => $paymentCode,
                );
            }
            return $methods;
        }
}
Related Topic