12

I have a question regarding Magento's local directory.

I am trying to override a core controller - Mage/Contacts/controllers/IndexController.php.

So I copied IndexController.php to /app/local/Mage/Contacts/controllers/

but Magento is still using core file. I can confirm it because I see 404 page when I rename Mage/Contacts/controllers/IndexController.php to IndexController.php_.

Please advise me.

Thanks!

Jonathan Day
  • 18,519
  • 10
  • 84
  • 137
Moon
  • 22,195
  • 68
  • 188
  • 269
  • 1
    Have the same problem, solution - http://stackoverflow.com/questions/19814600/magento-copy-controller-to-local?answertab=votes#tab-top – Lubomur Marshal Nov 07 '13 at 13:31

1 Answers1

20

Copying a controller into the app/code/local path doesn't work unfortunately due to Magento's autoload architecture. It does work with Blocks, Models and other objects, but not controllers.

There is a detailed walkthrough of how to override a controller on the wiki. And a blog post by @prattski

Try following those, then come back with any specific questions.

HTH, JD

Jonathan Day
  • 18,519
  • 10
  • 84
  • 137
  • For me it does not for with some blocks either (e.g. /local/Mage/GoogleAnalytics/Block/Ga.php). Would really like to know the algorithm Magento uses to determine when to use local directory instances and when not. – user487772 May 26 '11 at 10:40
  • Your links are dead now. Thats why you should always add all relevant informations to your post. – Black Sep 29 '20 at 10:15