PHP Magento Tips

Powered by Blogger.

How to Create Simple Frontend Controller In Magento

Rate this posting:

With this example, you can easily create a Simple frontend controller which is totally for a learning Purpose.

Step 1:

In app/etc/modules/Foo_Bar.xml add below code:

<?xml version="1.0" encoding="UTF-8"?>

Step 2:

In app/code/local/Foo/Bar/etc/config.xml add below code:

<?xml version="1.0" encoding="UTF-8"?>
    <frontend><!-- | adminhtml -->
        <foo_bar><!--just needs to be unique-->
            <use>standard</use> <!-- admin -->

Here <module> node match our module node in our Registration file.So, if you have any doubt about what to put there then just open main configuration file (app/etc/modules/Foo_Bar.xml Here) and look for text immediately after <modules> node. It is simply a folder path.

Step 3:

In app/code/local/Foo/Bar/controllers/PastaController.php add below code:


/// app/code/local/Foo/Bar/controllers/PastaController.php
class Foo_Bar_PastaController extends Mage_Core_Controller_Front_Action {
    public function sleepAction() {
        echo '<h1> I\'m so tired after eating yummy pasta</h1>';

Now open your front end with below url:



In our case frontname node is foo, controller is pasta and action is sleep. So, URL will become in this way.
0 Comments On "How to Create Simple Frontend Controller In Magento"

Back To Top