Shuan F
Shuan F

Reputation: 23

Magento - local cartcontroller is not working

I'm trying to overwrite the function couponPostAction in Magento, which is in the cartcontroller.

I created a new local Module Nf_Ajaxcoupon.

this is the config file

<?xml version="1.0"?>
<config>
    <modules>
        <Nf_Ajaxcoupon>
            <version>0.1.0</version>
        </Nf_Ajaxcoupon>
    </modules>
    <global>

        <rewrite>

            <Nf_Ajaxcoupon_checkout_cart>
                <from><![CDATA[#^/checkout/cart/#]]></from>

                <to>/Ajaxcoupon/checkout_cart/</to>
            </Nf_Ajaxcoupon_checkout_cart>
       </rewrite>
    </global>

    <frontend>
        <routers>
            <Nf_Ajaxcoupon>


                <use>standard</use>

                <args>

                    <module>Nf_Ajaxcoupon</module>



                    <frontName>Ajaxcoupon</frontName>

                </args>

            </Nf_Ajaxcoupon>

        </routers>

    </frontend>

</config>

This is my module activation:

<?xml version="1.0"?>
<config>
    <modules>
        <Nf_All>
            <active>true</active>
            <codePool>local</codePool>
        </Nf_All>
    </modules>
</config>

This is my CartController.php file:

<?php

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


class Nf_Ajaxcoupon_Checkout_CartController extends Mage_Checkout_CartController

  {


   function couponPostAction()
    {
    var_dump($_POST);
      die('local');


    }
  }

?>

I can't understand why its not calling the local controller, when I go to system->configuration->advanced I see it is enabled.

Any suggestions why its not working or ways to debug it?

Thanks

Upvotes: 1

Views: 440

Answers (1)

Anton S
Anton S

Reputation: 12750

This is the proper way to override a controller in config inside frontend node

<routers>
    <checkout>
        <args>
            <modules>
                <Nf_Ajaxcoupon before="Mage_Checkout">Nf_Ajaxcoupon_Checkout</Nf_Ajaxcoupon>
            </modules>
        </args>
    </checkout>
</routers>

also are you sure that your configure file would not need to be for Nf_Ajaxcoupon not to Nf_All

<?xml version="1.0"?>
<config>
    <modules>
        <Nf_Ajaxcoupon>
            <active>true</active>
            <codePool>local</codePool>
        </Nf_Ajaxcoupon>
    </modules>
</config>

Upvotes: 1

Related Questions