0
votes

I'm trying to extend the Creativestyle_AmazonPayments_Model_Service_Login class found in Service/Login.php model in the Amazon Payments Magento module.

I have my own module that I've written to patch up a few things in this module already but so far they've been block class rewrites and layout XML changes.

To achieve this, in my config.xml I've added:

    <models>
        <amazonpayments>
            <rewrite>
                <service_login>Glambert_AmazonPayments_Model_Service_Login</service_login>
            </rewrite>
        </amazonpayments>
    </models>

Then in app/code/local/Glambert/AmazonPayments/Model/Service/Login.php I've extended the class like this:

class Glambert_AmazonPayments_Model_Service_Login extends Creativestyle_AmazonPayments_Model_Service_Login {
 // code
}

As far as I can tell, that's enough to make the LoginController.php call this class when executing Mage::getModel('amazonpayments/service_login'); but it doesn't seem to work.

For debugging, I've added some logging into app/code/core/Mage/Core/Model/Config.php in the getGroupedClassName method to see what $this->_xml->global->{$groupType.'s'}->{$group} is returning when we're getting this model and the rewrite doesn't show up, just this:

Mage_Core_Model_Config_Element Object
(
    [class] => Creativestyle_AmazonPayments_Model
    [rewrite] => Mage_Core_Model_Config_Element Object
        (
            [checkout] => ThirdParty_Module_Model_AmazonPayments_Checkout
        )

)

I then thought I would add the ... line from my config.xml into the third party's config.xml to see if it added it to the array then... that didn't work either.

As a tester, I added this line into the getGroupedClassName method:

if($class == 'service_login') $config->rewrite->$class = 'Glambert_AmazonPayments_Model_Service_Login';

This did actually execute my code. This makes me think there is something wrong with the config.xml file?

UPDATE: it looks like the whole module Glambert_AmazonPayments is not working. This is on a development branch testing out an upgrade from 1.13.1 to 1.14, the module works fine on 1.13.1 but not on 1.14, nothing has changed apart from this one change to rewrite a model

1

1 Answers

0
votes

My fix was to Disable the module in Configuration -> Advanced -> Advanced, then re-enable it, then it worked. I don't know why this worked, but it did.