0

I wrote this code in config.xml, trying to rewrite product review post action.

<rewrite>
            <namespace_module>
                <from><![CDATA[#^/review/product/post/#]]></from>
                <to>/module/review/post/</to>
            </namespace_module>
</rewrite>

But but when I sumit form this redirecting me to homepage.

I have used this code too Overriding controller.

include_once"Mage/Review/controllers/ProductController.php";
class Namespace_Module_NewController extends Mage_Review_ProductController
{ 

please suggest what I am missing.

  • Try including the full path to the file when doing rewrites for controllers. Example: require_once Mage::getModuleDir('controllers', 'Mage_Review') . DS . 'ProductController.php'; – Ryan Street Mar 19 '15 at 16:51
  • Also, the config based rewrites are deprecated in Magento 1.6. Use Pradeep's answer below. – Ryan Street Mar 19 '15 at 16:52
3

for overriding the controller.create a custom module.

Step 1: Create a module xml yourpackgename_modulename.xml file at the app/etc/modules with the following content.

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

Step 2: Create modules config.xml file at app/code/local/Yourpackgename/Modulename/etc/config.xml with the following content

<?xml version="1.0" ?>
<config>
    <modules>
        <Yourpackagename_Modulename>
            <version>0.0.1</version> 
        </Yourpackagename_Modulename>
    </modules>
    <frontend>
        <routers>
            <review>
                <args>
                    <modules>
                        <yourpackagename_modulename before="Mage_Review">Yourpackagename_Modulename</yourpackagename_modulename> 
                    </modules>
                </args>
            </review>
        </routers>
    </frontend>
</config>

Step 3: Create ProductConroller.php under app/code/local/Yourpackgename/Modulename/controllers/ProductController.php with the following content

<?php
    require_once 'Mage/Review/controllers/ProductController.php';
    class Yourpackagename_Modulename_ProductController extends Mage_Review_ProductController
    {

        public function postAction(){
            // your code comes here
        }

    }
?>
| improve this answer | |
  • Thanks for answer. But it has not worked. It is submitting parent postAction() method. – johnwright121 Dec 19 '14 at 7:09
  • can you post your actual code here.so that i can check it – Pradeep Sanku Dec 19 '14 at 7:12
  • It is exactly same as you have suggested. But on postAction(), I just used echo "hi"; exit; to check it is coming in function or not. But it is not and submitting parent funtion – johnwright121 Dec 19 '14 at 7:25

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.