Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Alphabetical Order for Menu
 
Pharez
Jr. Member
 
Total Posts:  5
Joined:  2009-03-07
 

Hello. I would like to know what is needed to be done to get my menu to be in alphabetical order. Because it seems that you can’t put an order on the category section. Hope sumbody would help me with this. Thanks in advance

 
Magento Community Magento Community
Magento Community
Magento Community
 
NeilA
Moderator
 
Avatar
Total Posts:  1372
Joined:  2007-09-17
Blue Mountains, Oz
 

Actually, 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. wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pharez
Jr. Member
 
Total Posts:  5
Joined:  2009-03-07
 

I didn’t know that! Haha. Thanks a bunch :D

EDIT: Thank god u replied just in time. I was about to mess around with the mysql database already :D

 
Magento Community Magento Community
Magento Community
Magento Community
 
NeilA
Moderator
 
Avatar
Total Posts:  1372
Joined:  2007-09-17
Blue Mountains, Oz
 

You’re welcome… wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
samotosh
Jr. Member
 
Avatar
Total Posts:  2
Joined:  2012-07-22
 

First backup your topmenu.phtml then replace the following code in your new topmenu.phtml file ,

<?php $_helper = Mage::helper(\'catalog/category\') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php

function array_sort($array, $on, $order=SORT_ASC)
{
$new_array = array();
$sortable_array = array();

if (count($array) > 0) {
foreach ($array as $k => $v) {
if (is_array($v)) {
foreach ($v as $k2 => $v2) {
if ($k2 == $on) {
$sortable_array[$k] = $v2;
}
}
} else {
$sortable_array[$k] = $v;
}
}

switch ($order) {
case SORT_ASC:
asort($sortable_array);
break;
case SORT_DESC:
arsort($sortable_array);
break;
}

foreach ($sortable_array as $k => $v) {
$new_array[$k] = $array[$k];
}
}

return $new_array;
}

?>
<?php
$layer = Mage::getSingleton(\'catalog/layer\');
$_category = $layer->getCurrentCategory();
$currentCategoryId= $_category->getId();
?>
<div class=\"nav-container\">
<ul id=\"nav\">
<?php $_helper = Mage::helper(\'catalog/category\') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry(\'current_category\') ?>
<?php if (count($_categories) > 0): ?>
<?php foreach($_categories as $_category): ?>
<?php $_category = Mage::getModel(\'catalog/category\')->load($_category->getId()) ?>
<li><a href=\"<?php echo $_helper->getCategoryUrl($_category) ?>\"><span><?php echo $_category->getName(); ?></span></a>
<?php $catList = array();?>
<?php $_subcategories = $_category->getChildrenCategories() ?>
<?php foreach($_subcategories as $_subCategory) : ?>
<?php $catList[] = array(\'name\' => $_subCategory->getName(), \'url\' => $_subCategory->getUrl(), \'id\' => $_subCategory->getId());?>
<?php endforeach ?>
<?php $catList = array_sort($catList, \'name\', SORT_ASC);?>
<ul>
<?php if (count($catList) > 0): ?>
<?php $subcat=0?>
<?php foreach($catList as $_subCategory): ?>
<li><a href=\"<?php echo $_subCategory[\'url\'] ?>\"><span><?php echo $_subCategory[\'name\'] ?></span></a>
<?php $subCatList = array();?>
<?php $_subSubCat = Mage::getModel(\'catalog/category\')->load($_subCategory[\'id\']);
$_subSubCategories = $_subSubCat->getChildrenCategories();?>
<?php foreach($_subSubCategories as $_subSubCategory) : ?>

<?php $subCatList[] = array(\'name\' => $_subSubCategory[\'name\'], \'url\' => $_subSubCategory[\'url\']);?>
<?php endforeach ?>
<?php $subCatList = array_sort($subCatList, \'name\', SORT_ASC);?>
<?php if (count($subCatList) > 0): ?>
<ul>
<?php foreach($subCatList as $_subSubCat): ?>
<li><a href=\"<?php echo $_subSubCat[\'url\'] ?>\"><span><?php echo $_subSubCat[\'name\'] ?></span></a>
<?php endforeach; ?>
</li></ul>
<?php endif; ?>
</li>
<?php endforeach; ?>

<?php endif; ?>
</ul>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
</div>

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top