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

Creating Payment Override
 
weismannweb
Jr. Member
 
Total Posts:  6
Joined:  2008-02-08
NY
 

I cant seem to get this override working.  I think I have it right but I must not if it isn’t working.  Can anyone give some pointers:

Here is the app/code/local/Its/Payment/Etc/config.xml file:

<?xml version="1.0"?>
<config>
    <
modules>
        <
Its_Payment>
            <
version>0.1.0</version>
        </
Its_Payment>
    </
modules>
    <global>
    <
blocks>
            <
payment>
                <
rewrite>
                <
info_cc>Its_Payment_Block_Info_Cc</info_cc>
                </
rewrite>
            </
payment>
        </
blocks>
    
        <
models>
            <
payment>
                <
rewrite>
                    <
method_cc>Its_Payment_Model_Method_Cc</method_cc>
                </
rewrite>
            </
payment>
        </
models>
    </global>
</
config>

Here is app/code/local/Its/Payment/Block/Info/Cc.php:

class Its_Payment_Block_Info_Cc extends Mage_Payment_Block_Info_Cc
{
  
    
  
/**
     * Retrieve Cookie CC
     *
     * @return Zend_Date
     */
    
public function getCcCookie()
    
{      echo "<h1>getCcCookie</h1>";exit;
        
$ccCookie $this->getInfo()->getCcCookie();
        return 
$ccCookie;
    
}
    
 
}

Here is app/code/local/Its/Payment/Model/Method/Cc.php:

class Its_Payment_Model_Method_Cc extends Mage_Payment_Model_Method_Cc
{
    
    
/**
     * Assign data to info model instance
     *
     * @param   mixed $data
     * @return  Mage_Payment_Model_Info
     */
    
public function assignData($data)
    
{
    
    
echo "<h1>ran assigndata</h1>";exit;
        if (!(
$data instanceof Varien_Object)) {
            $data 
= new Varien_Object($data);
        
}
        $info 
$this->getInfoInstance();
        
$info->setCcType($data->getCcType())
            ->
setCcOwner($data->getCcOwner())
            ->
setCcLast4(substr($data->getCcNumber(), -4))
            ->
setCcNumber($data->getCcNumber())
            ->
setCcCid($data->getCcCid())
            ->
setCcExpMonth($data->getCcExpMonth())
            ->
setCcExpYear($data->getCcExpYear())
            ->
setCcCookie($data->getCcCookie());
        return 
$this;
    
}

  

}

And Finnaly /app/etc/modules.Its_All.xml:

<?xml version="1.0"?>
<config>
     <
modules>
        <
Its_Payment>
            <
active>true</active>
            <
codePool>local</codePool>
        </
Its_Payment>
         <
Its_Sales>
            <
active>true</active>
            <
codePool>local</codePool>
        </
Its_Sales>
     </
modules>
</
config>

Are their any pros out there that can tell me whats wrong.  This is my first attempt at a overriding module.  I had it all working by replacing core files but I want to be neat and follow good practices by overloading the base classes.  Thanks alot!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
LeeSaferite
Guru
 
Avatar
Total Posts:  322
Joined:  2007-08-31
Lake City, FL
 

app/code/local/Its/Payment/Etc/config.xml should be app/code/local/Its/Payment/etc/config.xml

You have the case of the ‘etc’ directory wrong

 
Magento Community Magento Community
Magento Community
Magento Community
 
LeeSaferite
Guru
 
Avatar
Total Posts:  322
Joined:  2007-08-31
Lake City, FL
 

Other than that, it looks perfect.  Kudos for doing it the ‘right’ way. =)

 
Magento Community Magento Community
Magento Community
Magento Community
 
weismannweb
Jr. Member
 
Total Posts:  6
Joined:  2008-02-08
NY
 

Yeah I looked at the case for the etc directory and I had just wrote it wrong in this post.  The case is correct in my store.  I thought I had it pretty correct and I cant figure out why it doesn’t work. 

As far as I know the functions should be overloaded now....do I need to call the parent function or anything and as far as I understand I don’t have to change the way the functions get called in the view templates right.

 
Magento Community Magento Community
Magento Community
Magento Community
 
weismannweb
Jr. Member
 
Total Posts:  6
Joined:  2008-02-08
NY
 

Thanks for giving this one a shot Lee!

Unfortunately I have had to settle for using a mage directory rather then doing it the right way because it just isnt working for me.  Can anyone help me solve this one?  The only thing I can think of is that the file names and locations can not be the same as the original files.  Is that the problem?  I just cant figure this one out...Although I am very familiar with creating modules for other open source programs and overriding OOP classes I am out of my element and new to magento.

 
Magento Community Magento Community
Magento Community
Magento Community
 
weismannweb
Jr. Member
 
Total Posts:  6
Joined:  2008-02-08
NY
 

I think I found what may be wrong.  Whenever you manually install or uninstall a custom extension it may be a good idea, if your having issues, to delete the following file:

/app/etc/use_cache.ser

I believe this is a cache file for extension config files.  I can’t test this on the store I was working on for this extension because I just ended up using a Mage override folder and now the site is live but if I work on the site again I will try deleting that file and seeing if my extension works.  I bet it will work right away.

I found this because I manually installed a module and tried uninstalling it.  When I uninstalled it by removing all the files for the module my store would all of a sudden show a blank page with only a line or two of wierd ���� symbols for characters the browser could not interpret.  I then realized after about 30 minutes of debugging, and because the module still worked without the config files, that their must be some kind of cache.

Hope this helps other people in the same boat.

 
Magento Community Magento Community
Magento Community
Magento Community
 
phlux0r
Member
 
Avatar
Total Posts:  73
Joined:  2008-03-09
Auckland, New Zealand
 

Yes, make sure you have all the caches disabled under cache management.

 
Magento Community Magento Community
Magento Community
Magento Community
 
nikola99
Member
 
Total Posts:  47
Joined:  2010-04-09
 

I was able to figure this thing out see: http://www.magentocommerce.com/boards/viewthread/35776/#t230627

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