0

I am trying to override Mage_Checkout's CartController's action addAction() but its not happening to override. Following is the scenario,

Community Module overriding just "protected function _goBack()" of Mage of CartController.php

<checkout>
   <args>
      <modules>
           <Idev_OneStepCheckout before="Mage_Checkout">
              Idev_OneStepCheckout
           </Idev_OneStepCheckout>
     </modules>
  </args>
</checkout>

Local Module overriding just "AjaxController.php"of community Module

<onestepcheckout>
    <args>
      <modules>
         <WoofDigital_OneStepCheckoutPhl before="Idev_OneStepCheckout">
             WoofDigital_OneStepCheckoutPhl
        </WoofDigital_OneStepCheckoutPhl>
     </modules>
   </args>
</onestepcheckout>

untill here everything working fine. But now I am need to override CartController.php 's addAction() in separate local module.

Second Local Module to override "CartController.php" 's addAction()

<onestepcheckout>
  <args>
    <modules>
        <JakeSharp_Waterlee before="Idev_OneStepCheckout">
            JakeSharp_Waterlee
        </JakeSharp_Waterlee>
    </modules>
  </args>
</onestepcheckout>

CartController.php

require_once  Mage::getModuleDir('controllers', 'Idev_OneStepCheckout').DS.'CartController.php';
class JakeSharp_Waterlee_CartController extends Idev_OneStepCheckout_CartController {
  public function addAction(){
     die('Dead');
  }
}

But its not doing in this controller.. Can anyone please guide me if I am making any mistake... Thanks

  • try changing to <JakeSharp_Waterlee before="WoofDigital_OneStepCheckoutPhl"> and require_once CartController.php of WoofDigital_OneStepCheckoutPhl module – subroutines Mar 24 '17 at 0:51
  • But WoofDigital_OneStepCheckoutPhl module does not has CartController.php , so you think it make sense to call a file which is not overridden in that module...? – sohaib Mar 24 '17 at 23:01
  • Then just override whatever controller that's extending the "AjaxController.php"of community Module – subroutines Mar 26 '17 at 22:55
0

You need to override the WoofDigital module with your new local module. You should also set up the module dependency correctly in your app/etc/modules/moduleName.xml file as well. This way you config is loaded in the correct order.

  • But WoofDigital module is not abstracting CartController.php of community / Mage module... but i need to override CartController.php in my new local module..... – sohaib Mar 24 '17 at 23:02
0

You need to override WoofDigital_OneStepCheckoutPhl instead of Idev_OneStepCheckout module in your local module. ie

<onestepcheckout>
  <args>
    <modules>
        <JakeSharp_Waterlee before="WoofDigital_OneStepCheckoutPhl">
            JakeSharp_Waterlee
        </JakeSharp_Waterlee>
    </modules>
  </args>
</onestepcheckout>

Your controller, you can keep as it is, since WoofDigital_OneStepCheckoutPhl do not rewrite CartController.php.

But you need to add dependencies in your local module in order to properly load them in order. So do this:

File : app/etc/modules/JakeSharp_Waterlee.xml

<config>
    <modules>
        <JakeSharp_Waterlee>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <WoofDigital_OneStepCheckoutPhl />
                <Idev_OneStepCheckout />
            </depends>
        </JakeSharp_Waterlee>
    </modules>
</config>
  • WoofDigital_OneStepCheckoutPhl module is not abstracting CartController.php, and I need to overriden the method from CartController.php CartController.php is getting overridden in community module, though the method i want to override is not even getting overriden in community module too. – sohaib Mar 24 '17 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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