How to filter payment method in one-page checkout in Magento?

Introduction Q: How will you filter the payment method in one-page checkout based on some conditions? A: There are different ways to do so. Some of them are: By overriding template: app/design/frontend/[interface]/[theme]/template/checkout/onepage/payment/methods.phtml By overriding method: Mage_Checkout_Block_Onepage_Payment_Methods::_canUseMethod() By overriding method: Mage_Payment_Model_Method_Abstract::isAvailable() By overriding method: Mage_Checkout_Block_Onepage_Payment_Methods::getMethods() By observing event: payment_method_is_active and so on. Among the above methods …

Read more

How to convert an array to a collection object in Magento?

Scenario Suppose say we have an array of data fetched from the database. And we want to merge it with Magento collection object or want to provide the data as collection object to the view(template) file. Solution <?php $resource = Mage::getModel(‘core/resource’); $connection = $resource->getConnection(‘core_read’); $sql = “SELECT * FROM custom_table WHERE some_field = ?”; $rows …

Read more

Adding upload field in the contact form and send as an attachment

Introduction Nowadays most of the clients want extra fields in contacts form of Magento to fulfill their requirements. And adding custom fields other than upload field (for example text, textarea, select, etc) in the contact form are easy in the sense you can easily include the field values in the contact email template. But adding …

Read more