By default, if the customers try to access a page that does not exist, they will be redirected to the page displaying “404 Page Not Found”. However, Magento allows you to customize the content of the page so that you can send another message to the customers or redirect them to another page. This tutorial will show you how to edit and customize the “404 Page Not Found” in Magento store (working with version 1.9).
Related tutorials:
- How to fix Magento Error 503 Service Temporarily Unavailable
- How to fix Magento 500 Internal Server Errors in Magento and Magento 2
Edit 404 page content
1. Login to the backend of your Magento store.
2. From the Admin dashboard, navigate to CMS >Page.
3. Explore the Manage Pages section. Click on the 404 Not Found 1 line:
4. Explore the Page Information. From the left-side menu, select Content:
- Edit the Content Heading and edit the content of the page in the content box.
- Click Save Page to finish.
Customize 404 page
Now we will customize 404 page to enhance its looking, let’s say you want to add specific category listing with products to the 404 page, do as follow.
Add product listing from a specific category
Go to your theme’s layout at app/design/frontend/yourpackage/yourtheme/layout/cms.xml
In line 92 find
1 | <cms_index_noroute translate="label"> |
add the following code:
1 2 3 4 5 6 7 8 9 10 11 | <span class="sy0"><</span>cms_index_noroute translate<span class="sy0">=</span><span class="st0">"label"</span><span class="sy0">></span> <span class="sy0"><</span>label<span class="sy0">></span>CMS No<span class="sy0">-</span>Route Page<span class="sy0"></</span>label<span class="sy0">></span> <span class="sy0"><</span>reference name<span class="sy0">=</span><span class="st0">"content"</span><span class="sy0">></span> <span class="sy0"><</span>remove name<span class="sy0">=</span><span class="st0">"cms.wrapper"</span><span class="sy0">/></span> <span class="sy0"><</span>block type<span class="sy0">=</span><span class="st0">"catalog/product_list"</span> name<span class="sy0">=</span><span class="st0">"your_category_name"</span> template<span class="sy0">=</span><span class="st0">"catalog/product/list.phtml"</span> after<span class="sy0">=</span><span class="st0">"page_content_heading"</span><span class="sy0">></span> <span class="sy0"><</span>action method<span class="sy0">=</span><span class="st0">"setCategoryId"</span><span class="sy0">><</span>category_id<span class="sy0">></span><span class="nu0">12</span><span class="sy0"></</span>category_id<span class="sy0">></</span>action<span class="sy0">></span> <span class="sy0"><</span>action method<span class="sy0">=</span><span class="st0">"setColumnCount"</span><span class="sy0">><</span>column_count<span class="sy0">></span><span class="nu0">5</span><span class="sy0"></</span>column_count<span class="sy0">></</span>action<span class="sy0">></span> <span class="sy0"><</span>action method<span class="sy0">=</span><span class="st0">"setDefaultGridPerPage"</span><span class="sy0">><</span>limit<span class="sy0">></span><span class="nu0">15</span><span class="sy0"></</span>limit<span class="sy0">></</span>action<span class="sy0">></span> <span class="sy0"></</span>block<span class="sy0">></span> <span class="sy0"></</span>reference<span class="sy0">></span> <span class="sy0"></</span>cms_index_noroute<span class="sy0">></span> |
Change category name and number of columns as you want.
Add quick search box
you can add the following code to cms.xml line 92
1 | <block type="core/template" name="top.search" as="topSearch" template="catalogsearch/form.mini.phtml"/> |
and the code will look like this
1 2 3 4 5 6 7 | <cms_index_noroute translate="label"> <label>CMS No-Route Page</label> <reference name="content"> <remove name="cms.wrapper"/> <block type="core/template" name="top.search" as="topSearch" template="catalogsearch/form.mini.phtml"/> </reference> </cms_index_noroute> |
There are even more things you can add to the 404 page, feel free to let me know by dropping a comment below
That comes to the end of the tutorial. if you have any further questions, please comment below to let us know.