I am trying to override a file in Controller and another in controllers directory of the Amazon Payments module. I have followed several tutorials with no luck at overriding the controllers and I have no idea how to override abstract classes in the Controller folder (capital C). I need to override two methods found in two different files indexAction() in OnepageController.php and _getOnepage() in Checkout.php.
app/code/community/Amazon/Payments/controllers/OnepageController.php
class Amazon_Payments_OnepageController extends Amazon_Payments_Controller_Checkout
{
...
public function indexAction()
{
// placeholder required
}
...
}
app/code/community/Amazon/Payments/Controller/Checkout.php
abstract class Amazon_Payments_Controller_Checkout extends Mage_Checkout_Controller_Action
{
...
protected function _getOnepage()
{
return Mage::getSingleton('checkout/type_onepage');
}
...
}
Does anyone see what I am doing wrong in my code that would get this working? Also does anyone know how to override the Checkout.php file at the bottom?
app/etc/modules/KNG_Amazon/Payments.xml
<?xml version="1.0"?>
<config>
<modules>
<KNG_Amazon_Payments>
<active>true</active>
<codePool>local</codePool>
<depends>
<Amazon_Payments />
</depends>
</KNG_Amazon_Payments>
</modules>
</config>
app/code/local/KNG/Amazon/Payments/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<KNG_Amazon_Payments>
<version>1.3.0.1</version>
</KNG_Amazon_Payments>
</modules>
<frontend>
<routers>
<amazon_payments>
<args>
<modules>
<KNG_Amazon_Payments before="Amazon_Payments">KNG_Amazon_Payments</KNG_Amazon_Payments>
</modules>
</args>
</amazon_payments>
</routers>
</frontend>
</config>
app/code/local/KNG/Amazon/Payments/controllers/OnepageController.php
require_once 'Amazon/Payments/controllers/OnepageController.php';
class KNG_Amazon_Payments_OnepageController extends Amazon_Payments_OnepageController
{
public function indexAction()
{
$this->_getOnepage()->savePayment(array(
'method' => 'amazon_payments',
'additional_information' => array(
'order_reference' => $this->getAmazonOrderReferenceId(),
)
));
}
}
As for this last file I don't have any idea how to override it but the change below to the method is what I am wanting from the result.
app/code/local/KNG/Amazon/Payments/Controller/Checkout.php
abstract class KNG_Amazon_Payments_Controller_Checkout extends Amazon_Payments_Controller_Checkout
{
protected function _getOnepage()
{
return Mage::getSingleton('amazon_payments/type_checkout');
}
}
Update: After some research I found out that I no longer need to override Checkout.php file. I like the answer that was given by @fschmengler, explaining the differences so I want to leave it. My problem right now is that my code for OnepageController.php is still not working. Can anyone help with that?
System > Configuration > Advance
. If your module name doesn't present there then your naming is wrong ex.KNG_Amazon_Payments
. As I have been doing for naming isNameSpace_ModuleName
.