3

I'm trying to override the successAction in the

app/code/core/Mage/Checkout/controllers/OnepageController.php.

I have done the following:
I've created my override folder here:

app/code/local/Ftml/Ig/controllers/OnepageController.php

I have a config file here:

app/code/local/Ftml/Ig/etc/config.xml

Here is the full XML of the config file. There are some other overrides here and an observer declared, and the observer is working, so I do believe that this file is being accessed and read:

<?xml version="1.0"?> <config> <modules> <Ftml_Ig> <version>0.0.1</version> </Ftml_Ig> </modules> <global> <models> <ig> <class>Ftml_Ig_Model</class> </ig> </models> <helpers> <ig> <class>Ftml_Ig_Helper</class> </ig> </helpers> <events> <checkout_onepage_controller_success_action> <observers> <ig_sales_order_success_action> <type>singleton</type> <class>ig/observer</class> <method>submitOrderData</method> </ig_sales_order_success_action> </observers> </checkout_onepage_controller_success_action> <cms_page_render> <observers> <ig_init_parameters> <type>singleton</type> <class>ig/observer</class> <method>initParameters</method> </ig_init_parameters> </observers> </cms_page_render> </events> </global> <frontend> <routers> <ig> <use>standard</use> <args> <module>Ftml_Ig</module> <frontName>ig</frontName> </args> </ig> <checkout> <args> <modules> <ig before="Mage_Checkout">Ftml_Ig</ig> </modules> </args> </checkout> </routers> </frontend> <adminhtml> <acl> <resources> <admin> <children> <system> <children> <config> <children> <cloud> <title>Cloud</title> </cloud> </children> </config> </children> </system> </children> </admin> </resources> </acl> </adminhtml> </config>

My module file is located in:

app/etc/modules/Ftml_Ig.xml

Here is the module XML:

<?xml version="1.0"?> <config> <modules> <Ftml_Ig> <active>true</active> <codePool>local</codePool> <depends> <Mage_Page /> <Mage_Checkout /> </depends> </Ftml_Ig> </modules> </config>

Finally, here is the code in my OnepageController.php file:

//require_once 'Mage/Checkout/controllers/OnepageController.php'; require_once(Mage::getModuleDir('controllers', 'Mage_Checkout').DS.'OnepageController.php'); class Ftml_Ig_OnepageController extends Mage_Checkout_OnepageController { /** * Order success action */ public function successAction() { Mage::log("=^..^=In success action in OVERRIDE OnePageController"); $session = $this->getOnepage()->getCheckout(); if (!$session->getLastSuccessQuoteId()) { $this->_redirect('checkout/cart'); return; } $lastQuoteId = $session->getLastQuoteId(); $lastOrderId = $session->getLastOrderId(); $lastRecurringProfiles = $session->getLastRecurringProfileIds(); if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) { $this->_redirect('checkout/cart'); return; } $session->clear(); $this->loadLayout(); $this->_initLayoutMessages('checkout/session');
Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId))); $this->renderLayout(); } }

In the config.xml file, I have tried changing the (modules ig) to (ftml_ig), but that doesn't work. I've tried changing my require statement in the Overriding OnepageController.php from:

require_once 'Mage/Checkout/controllers/OnepageController.php';

to

require_once Mage::getModuleDir('controllers', 'Mage_Checkout').DS.'OnepageController.php'

But that seems to have had no effect either. I know that I'm still hitting the core because I'm not seeing log messages that I've added in the Overriding controller, and I AM seeing log messages that I added temporarily to the core controller. Any assistance with this issue would be greatly appreciated. I am new to Magento and PHP.

Edited to add more detail

2
  • It seems like the configuration file that I'm writing in may not be getting used after all. I just tried commenting the entire thing out and it didn't affect anything. Either that, or there is some step I'm missing. I did try to restart the site using XAMPP interface, but still didn't see any of my changes showing up.
    – admiral142
    Feb 11, 2019 at 20:59
  • Found the issue! As I mentioned, I'm new to Magento (and PHP). The Cache was still turned on in Magento. I found how to turn that off and am now able to affect things with my config file. I'll try Sohel's solution now.
    – admiral142
    Feb 12, 2019 at 15:40

1 Answer 1

1

Try following way:

app/etc/modules/Ftml_Ig.xml


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

app/code/local/Ftml/Ig/etc/config.xml


<?xml version="1.0"?>
<config>
    <modules>
        <Ftml_Ig>
            <version>0.0.0.1</version>
        </Ftml_Ig>
    </modules>
    <frontend>
        <routers>
            <checkout>
                <args>
                    <modules>
                        <Ftml_Ig before="Mage_Checkout">Ftml_Ig</Ftml_Ig>
                    </modules>
                </args>
            </checkout>
        </routers>
    </frontend>
</config>

app/code/local/Ftml/Ig/controllers/OnepageController.php


<?php
require_once(Mage::getModuleDir('controllers','Mage_Checkout').DS.'OnepageController.php');
class Ftml_Ig_OnepageController extends Mage_Checkout_OnepageController
{
    /**
     * Order success action
     */
    public function successAction()
    {
        $session = $this->getOnepage()->getCheckout();
        if (!$session->getLastSuccessQuoteId()) {
            $this->_redirect('checkout/cart');
            return;
        }

        $lastQuoteId = $session->getLastQuoteId();
        $lastOrderId = $session->getLastOrderId();
        $lastRecurringProfiles = $session->getLastRecurringProfileIds();
        if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) {
            $this->_redirect('checkout/cart');
            return;
        }

        $session->clear();
        $this->loadLayout();
        $this->_initLayoutMessages('checkout/session');
        Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId)));
        $this->renderLayout();
    }
}

4
  • Thank you for your comment. My Ftml_Ig.xml looks like what you have posted, though I do also have Mage_Page in the <depends> section.
    – admiral142
    Feb 11, 2019 at 17:39
  • Did you try using my answer? Check directory spelling too. This is working fine.
    – Sohel Rana
    Feb 11, 2019 at 17:52
  • Sorry, I thought I deleted that comment! I was in the process of editing my original post to add more detail. I did try using your answer, and did not have success. I am thinking it has to do with the configuration file, I'm just not sure what I'm doing wrong there. I'm wondering if the other items in the configuration file are somehow affecting the override. If you have a chance to look at the additional detail I've added and if you see anything odd, I'd sure appreciate it. Thank you for your time!
    – admiral142
    Feb 11, 2019 at 18:06
  • Thank you, Sohel! Turns out this was a cache issue. The code that I had was working, but I had an old config cached. Thanks again!
    – admiral142
    Feb 12, 2019 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.