Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Custom Payment Module with custom templates. 
 
subesh
Sr. Member
 
Avatar
Total Posts:  145
Joined:  2009-01-08
 

I want to have a custom templates of info/default.phtml........ going with my module.. Help plz

 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

define info block in your payment module model:

protected $_infoBlockType 'custommodule/info_yourblock';

Create block file in custommodule/Block/Info/Yourblock.php extend this block with Mage_Payment_Block_Info

Add this methods to the block:

/**
     * Init default template for block
     */
    protected function _construct()
    
{
        parent
::_construct();
        
$this->setTemplate('custommodule/info/yourblock.phtml');
    
}
    
     
/**
     * Retrieve info model
     *
     * @return Mage_Sofortueberweisung_Model_Info
     */
    
public function getInfo()
    
{
        $info 
$this->getData('info');
        
        if (!(
$info instanceof Mage_Payment_Model_Info)) {
            Mage
::throwException($this->__('Can not retrieve payment info model object.'));
        
}
        
return $info;
    
}
    
     
/**
     * Retrieve payment method model
     *
     * @return Mage_Payment_Model_Method_Abstract
     */
    
public function getMethod()
    
{
        
return $this->getInfo()->getMethodInstance();
    
}
    
    
public function toPdf()
    
{
        $this
->setTemplate('custommodule/inofo/pdf/yourblock.phtml');
        return 
$this->toHtml();
    
}

Create this two phtml files:

custommodule/info/yourblock.phtml
custommodule/inofo/pdf/yourblock.phtml

hope thats helps.

cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
Manos Dilaverakis
Member
 
Total Posts:  49
Joined:  2009-02-25
 

You need to use your own block and view. Starting with your Model class you need to add this line:

protected $_infoBlockType 'module/info_module';
where “module” is the name of your module. This tells Magento to use your own Block class. Next we define where this can be found by adding
<blocks>
            <
module>
                <class>
Namespace_Module_Block</class>
            </
module>
        </
blocks>
in config.xml under <global>. This says that your block class(es) are somewhere in /app/code/[whatever]/Namespace/Module/Block.
In that folder we create a subfolder named Info and in there a file named Module.php (like we defined in the Model class at the beginning).
With that file we extend Mage_Payment_Block_Info like so:
<?php
class Namespace_Module_Block_Info_Module extends Mage_Payment_Block_Info
{
    
protected function _construct()
    
{
        parent
::_construct();
        
$this->setTemplate('payment/info/module.phtml');
    
}
}
which tells Magento which template to use for your module (/add/design/frontend/[interface]/[theme]/template/payment/info/module.phtml) . The templates for the existing payment methods are already in that folder so copy whichever most closely resembles what you want and make your changes there.

Edit: Damn, beaten to the punch

 
Magento Community Magento Community
Magento Community
Magento Community
 
subesh
Sr. Member
 
Avatar
Total Posts:  145
Joined:  2009-01-08
 

Thanx............ You’re the Man.............  You really saved my A**

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top