skip to Main Content

i’ve been trying to override the checkout controller from a community extension for 2 hours, and still not working.

My Custom module is activated .
Trying to rewrite (Community/Manv/Ajaxcoupon/controllers/Indexcontroller.php)
Here is my controller.

require_once 'Manv/Ajaxcoupon/controllers/IndexController.php';

    class Name_Promocode_CartController extends Manv_Ajaxcoupon_IndexController
    {

        public function customcouponPostAction(){
            die('custom');
        }

        public function couponPostAction()
        {
            die('We are in');
    }

Here is my config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Name_Promocode>
            <version>1.0.0</version>
        </Name_Promocode>
    </modules>
    <frontend>
        <routers>
          <checkout>
            <args>
              <modules>
                <Name_Promocode before="Manv_Ajaxcoupon">Name_Promocode</Name_Promocode>
              </modules>
            </args>
          </checkout>
        </routers>
    </frontend>
</config>

Deleted cache…
Can’t find what’s wrong, when i put a die() in the community module, i see it. But seems like my module isn’t overriding anythings.

3

Answers


  1. Chosen as BEST ANSWER

    Finally made it works with this config.xml

    <config>
        <modules>
            <Name_Promocode>
                <version>1.0.0</version>
            </Name_Promocode>
        </modules>
        <frontend>
            <routers>
              <name_promocode>
                    <use>standard</use>
                    <args>
                        <module>Name_Promocode</module>
                        <frontName>promocode</frontName>
                    </args>
              </name_promocode>
            </routers>
        </frontend>
        <global>
            <rewrite>
                <name_promocode> 
                    <from><![CDATA[#^/ajaxcoupon/index/#]]></from>  <!-- the URL which u want to override-->
                    <to>/promocode/cart/</to>  <!-- destination url -->
                </name_promocode>
            </rewrite>
        </global>
    </config>
    

    Hope this will help someone :D


  2. // Try compare with below config.xml code.

    <config>
        <frontend>
            <routers>
                <checkout>
                    <args>
                        <modules>
                            <name_promocode before="Mage_Tag">Manv_Ajaxcoupon</name_promocode>
                        </modules>
                    </args>
                </tag>
            </routers>
        </frontend>
    </config>
    

    //Alternate override controller code.

      <global>
            <!-- This rewrite rule could be added to the database instead -->
            <rewrite>
                <!-- This is an identifier for your rewrite that should be unique -->
                <!-- THIS IS THE CLASSNAME IN YOUR OWN CONTROLLER -->
                <customcontactsunique>
                    <from><![CDATA[#^/contacts/index/#]]></from>
                    <!--
                        - mymodule matches the router frontname below
                        -  matches the path to your controller
    
                        Considering the router below, "/customcontacts/index/" will be
                        "translated" to "app/code/local/Amit/Customcontacts/controllers/IndexController.php" (?)
                    -->
                    <to>/customcontacts/index/</to>
                </customcontactsunique>
            </rewrite>
        </global>
    

    //compare controller code.

        require_once(Mage::getModuleDir('controllers','Manv_Ajaxcoupon').DS.'IndexController.php');
    
    class Name_Promocode_CartController extends Manv_Ajaxcoupon_IndexController
    {
      // some code
    }
    

    More reference

    Alternate override controller link

    Login or Signup to reply.
  3. Try this out:

    <config>
        <modules>
            <Name_Promocode>
                <version>1.0.0</version>
            </Name_Promocode>
        </modules>
        <frontend>
            <routers>
              <name_promocode>
                    <use>standard</use>
                    <args>
                        <module>Name_Promocode</module>
                        <frontName>promocode</frontName>
                    </args>
              </name_promocode>
            </routers>
        </frontend>
        <global>
            <rewrite>
                <name_promocode> 
                    <from><![CDATA[#^/ajaxcoupon/index/#]]></from>  <!-- the URL which u want to override-->
                    <to>/promocode/cart/</to>  <!-- destination url -->
                </name_promocode>
            </rewrite>
        </global>
    </config>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search