0
votes

I am trying to override/extend the Ebizmarts SagePay Suite Ebizmarts_SagePaySuite_Model_Api_Payment model class

My module looks like this:

etc/modules/Sulman_ModifySagePay.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Sulman_ModifySagePay>
            <active>true</active>
            <codePool>local</codePool>
            <version>1.0</version>
            <depends>
                <Ebizmarts_SagePaySuite />
            </depends>
        </Sulman_ModifySagePay>
    </modules>
</config>

app/code/local/Sulman/ModifySagePay/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Sulman_ModifySagePay>
            <version>0.0.1</version>
        </Sulman_ModifySagePay>
    </modules>
    <global>
        <models>
            <sagepaysuite>
                <rewrite>
                    <api_payment>Sulman_ModifySagePay_Model_Api_Payment</api_payment>
                </rewrite>
            </sagepaysuite>
        </models>
    </global>
</config>

app/code/local/Sulman/ModifySagePay/Model/Api/Payment.php

<?php

class Sulman_ModifySagePay_Model_Api_Payment extends Ebizmarts_SagePaySuite_Model_Api_Payment {

    public function _construct(){
        Mage::log('in my construct()', null, 'Sulman.log');
    }

    public function requestPost($url, $data, $returnRaw = false) {
        Mage::log('in my requestPost()', null, 'Sulman.log');
    }
}

Nothing gets logged and this gives me errors on the checkout page because:

When I check to see if it is instantiated it returns false (if I disable my module it returns the Ebizmarts_SagePaySuite_Model_Api_Payment object):

var_dump(Mage::getModel('sagepaysuite/api_payment'));

Other calls to this model throughout the site also fail.

I'm a little confused as it seems my rewrite is working correctly but it can't seem to find my new model class.

Anyone have any ideas where I'm going wrong?

Thanks

1
What are you trying to achieve? I think you should not rewrite Ebizmarts_SagePaySuite_Model_Api_Payment, instead focus on the child classes like Ebizmarts_SagePaySuite_Model_SagePayDirectPro. If you can tell me what you want to achieve I can help you.Pablo

1 Answers

0
votes

In your app/code/local/Sulman/ModifySagePay/etc/config.xml in the <models></models> section you need to define where your models are located:


<models>
    <modifysagepay>
        <class>Sulman_ModifySagePay_Model</class>
    <modifysagepay>
</models>