下面这段代码会获得所有启用的支付模块。下面的例子返回一个数组,你可以使用它在前台或后台创建下拉菜单或其他东西。
class Inchoo_Vendor_Model_Activpayment { public function getActivPaymentMethods() { $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; } }
原文地址:http://inchoo.net/ecommerce/magento/magento-how-to-get-all-active-payment-modules/