Override index controller magento

Here you can see how to override app/code/core/Mage/Contacts/controllers/IndexController.php .

1) Change the directory to the root of magento installation

2) vi app/etc/modules/PHPCodez_Contacts.xml

Paste the below given content

3) cd app/code/

4) mkdir local

5) cd local

6) mkdir PHPCodez

7) cd PHPCodez

8) mkdir Contacts

9) cd Contacts

10) mkdir controllers

11) mkdir etc

12) vi etc/config.xml

paste the below given code

<?xml version=”1.0″?>


12)vi controllers/IndexController.php

Paste the below given code

require_once ‘Mage/Contacts/controllers/IndexController.php’;
class PHPCodez_Contacts_IndexController extends Mage_Contacts_IndexController
// Overrride the post function
public function postAction() {
error_log(“Overriden n”, 3, “/var/log/error-log.txt”);
// add your code to implement a tasks