Note that there are some explanatory texts on larger screens.

plurals
  1. POMagento overloading a controller
    text
    copied!<p>I know there are a lot of examples out there for this issue and i think i read all of them, at least I feel so, a little bit confused :-) I think first of all i need basic conzept respectively a better appreciation of how is the best way to change the whole customer frontend dashboard and extend it with additional methods. I stuck a litte bit with this, maybe this is the wrong way, maybe not, hopefully you can help me finding the right way. </p> <p>All needed files are located in:</p> <p><strong>app/code/local/Company/Customer/etc/config.xml</strong></p> <p><strong>app/code/local/Company/Customer/controllers/AccountController.php</strong></p> <p><strong>app/code/local/Company/Customer/controllers/IndexController.php</strong></p> <p>Atm I play with these path's:</p> <p><strong>domain.com/customer/</strong></p> <p>overwritten by:</p> <pre><code>&lt;frontend&gt; &lt;routers&gt; &lt;customer&gt; &lt;use&gt;standard&lt;/use&gt; &lt;args&gt; &lt;module&gt;Company_Customer&lt;/module&gt; &lt;frontName&gt;customer&lt;/frontName&gt; &lt;/args&gt; &lt;/customer&gt; &lt;/routers&gt; &lt;/frontend&gt; </code></pre> <p>the above code is working, the overloading class is executed with the following function:</p> <p><code>function indexAction();</code></p> <p>and the path: <strong>domain.com/customer/</strong> or <strong>domain.com/customer/index/</strong> is functional.</p> <p>So far, so good. But now I also need all the other path's and their functionality, e.g. the <strong>domain.com/customer/account/</strong> path, normally executed and routed to the following path:</p> <p><strong>app/code/core/Mage/Customer/controllers/AccountController.php</strong></p> <p>and here's the crux, is it possible to load the AccountController by execute or load them in the IndexController.php class with a new method e.g. <code>function accountAction();</code> and stop Magento routing to the above core path? Or is it better to do this the way I did by rewrite the magento router to my own module, to:</p> <p><strong>app/code/local/Company/Customer/controllers/AccountController.php</strong></p> <p>Maybe there are some other ways but my router isn't working:</p> <pre><code>&lt;frontend&gt; &lt;routers&gt; &lt;customer_account&gt; &lt;use&gt;standard&lt;/use&gt; &lt;args&gt; &lt;module&gt;Company_Customer_Account&lt;/module&gt; &lt;frontName&gt;customer_account&lt;/frontName&gt; &lt;/args&gt; &lt;/customer_account&gt; &lt;/routers&gt; &lt;/frontend&gt; </code></pre> <p><strong>EDIT:</strong></p> <p>This is the from the error.log:</p> <pre><code>2011-07-25T10:36:46+00:00 ERR (3): Warning: include() [&lt;a href='function.include'&gt;function.include&lt;/a&gt;]: Failed opening 'Mage/Customer/AccountController.php' for inclusion (include_path='/html/magento/app/code/local:/html/magento/app/code/community:/html/magento/app/code/core:/html/magento/lib:.:/usr/local/php/lib/php:/usr/local/php/lib/php/PEAR') in /html/magento/lib/Varien/Autoload.php on line 93 </code></pre> <p>I think this means that the router works but the file isn't found, right?!</p> <p>Any suggestions would be great. Thanks!</p> <p><strong>--------------------------------------------</strong></p> <p><strong>----------------UPDATE----------------</strong></p> <p><strong>--------------------------------------------</strong></p> <p>Thanks for your reply. I allready tried the alternative rewrite in the global section before:</p> <pre><code>&lt;rewrite&gt; &lt;Company_Customer_Account&gt; &lt;from&gt;&lt;![CDATA[#^/customer/account/#]]&gt;&lt;/from&gt; &lt;to&gt;/customer/account/&lt;/to&gt; &lt;/Company_Customer_Account&gt; &lt;/rewrite&gt; </code></pre> <p>and with your code:</p> <pre><code>&lt;rewrite&gt; &lt;Company_Customer_Account&gt; &lt;from&gt;/customer/account/index/&lt;/from&gt; &lt;to&gt;/customer/account/index/&lt;/to&gt; &lt;/Company_Customer_Account&gt; &lt;/rewrite&gt; </code></pre> <p>both don't work, what i'm missing?</p> <p>Here's the AccountController.php</p> <pre><code>&lt;?php //require_once 'Mage/Customer/controllers/AccountController.php'; class Extension_Modul_AccountController extends Mage_Customer_AccountController { # Overloaded indexAction public function indexAction() { echo "executed"; parent::indexAction(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload