Magento : menu items order
Posted by lhe | Posted in Coding, Databases, E-Commerce, Magento, MySQL, PHP | Posted on 19-10-2010
5
We have been working on some Magento e-shops and it needs to be said, its a nice enough system.
However, it is not a CMS. This means that when you create pages, you dont have all the freedom you would enjoy when using Drupal or WordPress for example.
You can create pages and they will appear in the main menu. But then you start looking at the sort order of those menu items.
Guess what, nothing to be found in the admin interface to control it. So you go ” NOOOOOOOOOOoooooooooo….”……
No panic! Stay calm… with some minor db data changes and a little coding we can get it all to work.
First of all, let’s ask the obvious question “Why on earth is it not a standard admin function to be able to manipulate the page order?”
No idea, but it is foreseen in the database.
In the table
cms_page
you will find a collumn called
sort_order
. You can use this collumn to decide on the order.
Go refresh your page… Nothing changed, right? Hehe, well you need to do one more thing.
Open this file :
magento/app/design/frontend/default/maried/template/catalog/navigation
Find this line (should be line number 60):
$cms_pages->getSelect()->where('is_active = 1');
And add the sortorder so the line becomes :
$cms_pages->getSelect()->where('is_active = 1')->order('sort_order');
Now go and refresh your page… TADA!!!



Thanks for the post, good to know where that code is but aren’t you editing a core file?
Plus how do you change the sort_order? I know I can do it in the database but would be good to see some code that enabled this functionality in the backend for clients.
Hi Marc,
In our current Magento setup, the sort order field is available under the edit page screen at “CMS -> Static Pages”.
It’s displayed as a plain text field, used to input a integer number. What we describe in this article, is the theming method to sort your cms pages in your navigation, based on this sort order. As to the question if we are changing core files: no we aren’t
Greets,
Kim
You can set the order in catagories: when in category view, working with the category tree on the left, just drag and drop the categories into the order you want.
Hi there,
Nice to read thar you guys are experienced in Magento development: We are just about to launch a small webshop on the newspaper site http://na.se. Maybe there will be questions
hi Eric !
don’t hesitate to contact us in case you need more help. Maybe best that i come over to look at your issues might you have some
cheers!