Debugging Magento Error 404 Page

Debugging Magento Error 404 Page

Liam Firth

Generally, one of the most common Magento questions usually revolves around a Magento error, or more specifically why the Magento MVC controller 404.  While powerful, the configuration based MVC system that Magento currently uses still leaves a lot of room for errors.

It’s actually fairly easy for a Magento error to occur.  In Magento, you have to be able to name what is known as the ‘controller file’ precisely, as well as have an understanding of how to use a multiple node XML configuration string.  This multiple XML node configuration is used in the config.xml file.  If you’re unfamiliar with this term, it will typically contain terms such as args, router and frontName.  All of these terms will be familiar to a programmer, however, the subtle meanings of these terms are unclear in Magento.

Here, we’re taking a look at how you can debug your Magento error 404 page.

What are 404 Pages?

In most cases, a PHP framework will include a programmatic 404 page.  If you’re new to PHP frameworks, this basically means that it will sometimes throw out an exception.  This will let you know that it couldn’t find a specific route to a controller action method.  This controller action method refers to the specific URL you have inputted.

Magento does come with a default 404 error page.  However, things are a little more complicated as Magento is required to market itself to different users.  Due to these different marketing requirements, you will find that the stock Magento error 404 page is just your typical end-user 404 page.

While developers who have more experience using Magento will easily recognise this page as the no route 404 page, newer developers will not. Also, you are not given any sort of hint as to why the system has produced a 404 error.

Debugging a Route in Magento

If you opt to use a Better 404 module, this can help you to determine why a certain URL offers no MVC route.  This is done in three simple steps:

  1. Does a module claim the front name?
  2. If yes, does the module include a correctly names controller file?
  3. If the answer is yes again, does the controller object include a correctly named action method?

Front Names and Config.xml

If you install the Better 404 module, when the Magento error 404 page shows up, you will see both the original path and the module/front name.  If you see an error appear where no modules claim [no-such-page] as a specific front name, then there is an issue with your config.xml file.  In this instance, a Magento error 404 page has appeared because Magento is unable to find a module that ‘claims’ the URL front name.

For those of you unfamiliar with ‘front name’, in this framework, each PHP module owns a specific URL.

For any novice developers, controller routing is one of the first steps in developing how to program Magento.  Using the Better 404 module will give you a better understanding of what is causing the Magento error 404 page.

Let us know if you found installing the Better 404 module useful in the comments section below.

Liam Firth

Author Liam Firth

More posts by Liam Firth