More Magento Annoyances

This week I had to deal with yet more stupid Magento behaviour. First, I had to overload a core controller class. Naively, I tried doing it the easy way at first—ie: simply duplicating the file and file path in the /app/code/local directory and making my changes there. (Which, BTW, always struck me as a deeply stupid way to go about things, but that’s another story)—but that didn’t work.

This week I had to deal with yet more stupid Magento behaviour. First, I had to overload a core controller class. Naively, I tried doing it the easy way at first—ie: simply duplicating the file and file path in the /app/code/local directory and making my changes there. (Which, BTW, always struck me as a deeply stupid way to go about things, but that’s another story)—but that didn’t work. A further bit of research told me that hey, controllers can’t be overridden that way. What you have to do, apparently, is create your own extension, with a controller class extending the core class, and perform other configuration magic.

Read the whole tutorial in the official Wiki here. Speaking of, I’m a little appalled at how incomplete and in need of a cleanup this article is, for what you’d think is a pretty important operation. Not only that, but the editors can’t even seem to agree on the details. For example, regarding Step 2, should the rewritten URL in the config file contain a leading slash or not? For the record, I did need those slashes, but maybe that depends on the version. That, plus lines like

(comments I’m not a 100% sure about are ending with “(?)”):

and

You need to get extra precise with the rewrite regular expression cause this causes a very hard time. In this part.

make the article look really unprofessional. Guys, it’s your freaking official freaking Wiki, you need to (a) be 110% sure about what you’re putting up, and (b) write in correct English. Sheesh.

Anyway. So I followed the instructions and it worked. Yay? But wait! In a crazy twist, my override controller (ie: in the extension) was actually extending my local controller (ie: the duplicate of the core class, that I’d forgotten to delete). So… a local override could have worked after all? Or is it a bug? I have no idea. I decided to just delete the local override and call it a day.

(There was another issue that at first I blamed on a Magento default template, but on mature reflection may have been caused by our team.)