order sub categories alphabetically The Next CEO of Stack OverflowList categories...

% symbol leads to superlong (forever?) compilations

Can a single photon have an energy density?

Should I tutor a student who I know has cheated on their homework?

If the heap is initialized for security, then why is the stack uninitialized?

Where to find order of arguments for default functions

Horror movie/show or scene where a horse creature opens its mouth really wide and devours a man in a stables

Why is there a PLL in CPU?

How did people program for Consoles with multiple CPUs?

How do I get the green key off the shelf in the Dobby level of Lego Harry Potter 2?

Unreliable Magic - Is it worth it?

Does it take more energy to get to Venus or to Mars?

Text adventure game code

How to start emacs in "nothing" mode (`fundamental-mode`)

Anatomically Correct Strange Women In Ponds Distributing Swords

Too much space between section and text in a twocolumn document

Why didn't Theresa May consult with Parliament before negotiating a deal with the EU?

Can a caster that cast Polymorph on themselves stop concentrating at any point even if their Int is low?

What is the difference between "behavior" and "behaviour"?

How to safely derail a train during transit?

What is the point of a new vote on May's deal when the indicative votes suggest she will not win?

How to count occurrences of text in a file?

Example of a Mathematician/Physicist whose Other Publications during their PhD eclipsed their PhD Thesis

How do we know the LHC results are robust?

Fastest way to shutdown Ubuntu Mate 18.10



order sub categories alphabetically



The Next CEO of Stack OverflowList categories alphabeticallyhow to display sub-sub categories on left sideGet parent category in home page with .phtml temapleList of Category IDs in orderMagento Multi-store Products not DisplayingNeed help with categories system, nav and layered navMagento 2 - Retrieve categoriesList Categories on a CMS Page A-Z StyleHow do I create a new URL with a list of existing productsGet all 3rd level categories












1















I have spent hours searching forums and trying several methods but cant get anywhere. does anyone know how to order all sub categories in magento to display alphabetically front end A-Z?










share|improve this question

























  • in layered navigation ?

    – Rajeev K Tomy
    Aug 29 '14 at 15:31











  • yes, layered navigation

    – rachael
    Sep 1 '14 at 9:27
















1















I have spent hours searching forums and trying several methods but cant get anywhere. does anyone know how to order all sub categories in magento to display alphabetically front end A-Z?










share|improve this question

























  • in layered navigation ?

    – Rajeev K Tomy
    Aug 29 '14 at 15:31











  • yes, layered navigation

    – rachael
    Sep 1 '14 at 9:27














1












1








1


1






I have spent hours searching forums and trying several methods but cant get anywhere. does anyone know how to order all sub categories in magento to display alphabetically front end A-Z?










share|improve this question
















I have spent hours searching forums and trying several methods but cant get anywhere. does anyone know how to order all sub categories in magento to display alphabetically front end A-Z?







category-tree






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 mins ago









Teja Bhagavan Kollepara

3,01241949




3,01241949










asked Aug 29 '14 at 15:11









rachaelrachael

63




63













  • in layered navigation ?

    – Rajeev K Tomy
    Aug 29 '14 at 15:31











  • yes, layered navigation

    – rachael
    Sep 1 '14 at 9:27



















  • in layered navigation ?

    – Rajeev K Tomy
    Aug 29 '14 at 15:31











  • yes, layered navigation

    – rachael
    Sep 1 '14 at 9:27

















in layered navigation ?

– Rajeev K Tomy
Aug 29 '14 at 15:31





in layered navigation ?

– Rajeev K Tomy
Aug 29 '14 at 15:31













yes, layered navigation

– rachael
Sep 1 '14 at 9:27





yes, layered navigation

– rachael
Sep 1 '14 at 9:27










1 Answer
1






active

oldest

votes


















3














if you take a look on the template file for layered navigation (cataloglayerview.phtml), you can see that, layered navigation filtering is carried out by this call



<?php $_filters = $this->getFilters() ?>


So take a look on getFilters() method in Mage_Catalog_Block_Layer_View block class.



public function getFilters()
{
$filters = array();
if ($categoryFilter = $this->_getCategoryFilter()) {
$filters[] = $categoryFilter;
}

$filterableAttributes = $this->_getFilterableAttributes();
foreach ($filterableAttributes as $attribute) {
$filters[] = $this->getChild($attribute->getAttributeCode() . '_filter');
}

return $filters;
}


Here you can see that, the method returns an array $filters, which is get filled in two sections. First the array get filled by category filters then it is filled by custom attribute filters. This means that, category filters are available in layered navigation by default



If we dig more and more, we will reach in the model class Mage_Catalog_Model_Layer_Filter_Category, where the actual category filters for layered navigations are carried out. The method that we interested here is _getItemsData()



 protected function _getItemsData()
{
$key = $this->getLayer()->getStateKey().'_SUBCATEGORIES';
$data = $this->getLayer()->getAggregator()->getCacheData($key);

if ($data === null) {
$categoty = $this->getCategory();
/** @var $categoty Mage_Catalog_Model_Categeory */
$categories = $categoty->getChildrenCategories();

$this->getLayer()->getProductCollection()
->addCountToCategories($categories);

$data = array();
foreach ($categories as $category) {
if ($category->getIsActive() && $category->getProductCount()) {
$data[] = array(
'label' => Mage::helper('core')->escapeHtml($category->getName()),
'value' => $category->getId(),
'count' => $category->getProductCount(),
);
}
}
$tags = $this->getLayer()->getStateTags();
$this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
}
return $data;
}


This is where category filters are preparing. The heart of this function is foreach. It uses that loop to load the $data variable(holds an array) which is then return to layered navigation filter. You can again see that, $data holds only 3 parameter of a specific category. They are label,value and children count. So the category section that present in layered navigation actually built up with these three values.



So this is the place that we need to work. By default categories are loading in random, means no filtering is applying there. What we need to do is, we need to sort the $data variable in ascending order.



So rewrite this model as like this.



 protected function _getItemsData()
{
$key = $this->getLayer()->getStateKey().'_SUBCATEGORIES';
$data = $this->getLayer()->getAggregator()->getCacheData($key);

if ($data === null) {
$categoty = $this->getCategory();
/** @var $categoty Mage_Catalog_Model_Categeory */
$categories = $categoty->getChildrenCategories();

$this->getLayer()->getProductCollection()
->addCountToCategories($categories);

$data = array();

foreach ($categories as $category) {
if ($category->getIsActive() && $category->getProductCount()) {
$data[] = array(
'label' => Mage::helper('core')->escapeHtml($category->getName()),
'value' => $category->getId(),
'count' => $category->getProductCount(),
);
}
}

function cmp($a, $b)
{
return strcmp($a["label"], $b["label"]);
}
usort($data, "cmp");
$tags = $this->getLayer()->getStateTags();
$this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
}
return $data;
}


This is the additional part that do the job for us



        function cmp($a, $b)
{
return strcmp($a["label"], $b["label"]);
}
usort($data, "cmp");


This will filter categories in ascending order for layered navigation.



Note:: You are lucky, I have this in extension format. You can use it. This is the github page that holds that extension. Feel free to use it






share|improve this answer
























  • hi many thanks for taking your time to get back to me. I downloaded your extension and uploaded the files to my ftp but navigation still isnt ordering sub categories a-z - is there something else i need to do? thanks

    – rachael
    Sep 1 '14 at 12:02











  • magento version ?

    – Rajeev K Tomy
    Sep 1 '14 at 12:03











  • Magento ver. 1.9.0.1

    – rachael
    Sep 1 '14 at 12:11











  • no way.. I have checked. It is working for me. are you sure you put my extension correctly and please note the extension sort category part of layered navigation, not any other part

    – Rajeev K Tomy
    Sep 1 '14 at 12:14











  • hi yeah i just placed full app directory to my website and cleared cache but still not sorting a-z in layered nav.. perhaps because i have custom theme?

    – rachael
    Sep 1 '14 at 12:16












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f34071%2forder-sub-categories-alphabetically%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














if you take a look on the template file for layered navigation (cataloglayerview.phtml), you can see that, layered navigation filtering is carried out by this call



<?php $_filters = $this->getFilters() ?>


So take a look on getFilters() method in Mage_Catalog_Block_Layer_View block class.



public function getFilters()
{
$filters = array();
if ($categoryFilter = $this->_getCategoryFilter()) {
$filters[] = $categoryFilter;
}

$filterableAttributes = $this->_getFilterableAttributes();
foreach ($filterableAttributes as $attribute) {
$filters[] = $this->getChild($attribute->getAttributeCode() . '_filter');
}

return $filters;
}


Here you can see that, the method returns an array $filters, which is get filled in two sections. First the array get filled by category filters then it is filled by custom attribute filters. This means that, category filters are available in layered navigation by default



If we dig more and more, we will reach in the model class Mage_Catalog_Model_Layer_Filter_Category, where the actual category filters for layered navigations are carried out. The method that we interested here is _getItemsData()



 protected function _getItemsData()
{
$key = $this->getLayer()->getStateKey().'_SUBCATEGORIES';
$data = $this->getLayer()->getAggregator()->getCacheData($key);

if ($data === null) {
$categoty = $this->getCategory();
/** @var $categoty Mage_Catalog_Model_Categeory */
$categories = $categoty->getChildrenCategories();

$this->getLayer()->getProductCollection()
->addCountToCategories($categories);

$data = array();
foreach ($categories as $category) {
if ($category->getIsActive() && $category->getProductCount()) {
$data[] = array(
'label' => Mage::helper('core')->escapeHtml($category->getName()),
'value' => $category->getId(),
'count' => $category->getProductCount(),
);
}
}
$tags = $this->getLayer()->getStateTags();
$this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
}
return $data;
}


This is where category filters are preparing. The heart of this function is foreach. It uses that loop to load the $data variable(holds an array) which is then return to layered navigation filter. You can again see that, $data holds only 3 parameter of a specific category. They are label,value and children count. So the category section that present in layered navigation actually built up with these three values.



So this is the place that we need to work. By default categories are loading in random, means no filtering is applying there. What we need to do is, we need to sort the $data variable in ascending order.



So rewrite this model as like this.



 protected function _getItemsData()
{
$key = $this->getLayer()->getStateKey().'_SUBCATEGORIES';
$data = $this->getLayer()->getAggregator()->getCacheData($key);

if ($data === null) {
$categoty = $this->getCategory();
/** @var $categoty Mage_Catalog_Model_Categeory */
$categories = $categoty->getChildrenCategories();

$this->getLayer()->getProductCollection()
->addCountToCategories($categories);

$data = array();

foreach ($categories as $category) {
if ($category->getIsActive() && $category->getProductCount()) {
$data[] = array(
'label' => Mage::helper('core')->escapeHtml($category->getName()),
'value' => $category->getId(),
'count' => $category->getProductCount(),
);
}
}

function cmp($a, $b)
{
return strcmp($a["label"], $b["label"]);
}
usort($data, "cmp");
$tags = $this->getLayer()->getStateTags();
$this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
}
return $data;
}


This is the additional part that do the job for us



        function cmp($a, $b)
{
return strcmp($a["label"], $b["label"]);
}
usort($data, "cmp");


This will filter categories in ascending order for layered navigation.



Note:: You are lucky, I have this in extension format. You can use it. This is the github page that holds that extension. Feel free to use it






share|improve this answer
























  • hi many thanks for taking your time to get back to me. I downloaded your extension and uploaded the files to my ftp but navigation still isnt ordering sub categories a-z - is there something else i need to do? thanks

    – rachael
    Sep 1 '14 at 12:02











  • magento version ?

    – Rajeev K Tomy
    Sep 1 '14 at 12:03











  • Magento ver. 1.9.0.1

    – rachael
    Sep 1 '14 at 12:11











  • no way.. I have checked. It is working for me. are you sure you put my extension correctly and please note the extension sort category part of layered navigation, not any other part

    – Rajeev K Tomy
    Sep 1 '14 at 12:14











  • hi yeah i just placed full app directory to my website and cleared cache but still not sorting a-z in layered nav.. perhaps because i have custom theme?

    – rachael
    Sep 1 '14 at 12:16
















3














if you take a look on the template file for layered navigation (cataloglayerview.phtml), you can see that, layered navigation filtering is carried out by this call



<?php $_filters = $this->getFilters() ?>


So take a look on getFilters() method in Mage_Catalog_Block_Layer_View block class.



public function getFilters()
{
$filters = array();
if ($categoryFilter = $this->_getCategoryFilter()) {
$filters[] = $categoryFilter;
}

$filterableAttributes = $this->_getFilterableAttributes();
foreach ($filterableAttributes as $attribute) {
$filters[] = $this->getChild($attribute->getAttributeCode() . '_filter');
}

return $filters;
}


Here you can see that, the method returns an array $filters, which is get filled in two sections. First the array get filled by category filters then it is filled by custom attribute filters. This means that, category filters are available in layered navigation by default



If we dig more and more, we will reach in the model class Mage_Catalog_Model_Layer_Filter_Category, where the actual category filters for layered navigations are carried out. The method that we interested here is _getItemsData()



 protected function _getItemsData()
{
$key = $this->getLayer()->getStateKey().'_SUBCATEGORIES';
$data = $this->getLayer()->getAggregator()->getCacheData($key);

if ($data === null) {
$categoty = $this->getCategory();
/** @var $categoty Mage_Catalog_Model_Categeory */
$categories = $categoty->getChildrenCategories();

$this->getLayer()->getProductCollection()
->addCountToCategories($categories);

$data = array();
foreach ($categories as $category) {
if ($category->getIsActive() && $category->getProductCount()) {
$data[] = array(
'label' => Mage::helper('core')->escapeHtml($category->getName()),
'value' => $category->getId(),
'count' => $category->getProductCount(),
);
}
}
$tags = $this->getLayer()->getStateTags();
$this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
}
return $data;
}


This is where category filters are preparing. The heart of this function is foreach. It uses that loop to load the $data variable(holds an array) which is then return to layered navigation filter. You can again see that, $data holds only 3 parameter of a specific category. They are label,value and children count. So the category section that present in layered navigation actually built up with these three values.



So this is the place that we need to work. By default categories are loading in random, means no filtering is applying there. What we need to do is, we need to sort the $data variable in ascending order.



So rewrite this model as like this.



 protected function _getItemsData()
{
$key = $this->getLayer()->getStateKey().'_SUBCATEGORIES';
$data = $this->getLayer()->getAggregator()->getCacheData($key);

if ($data === null) {
$categoty = $this->getCategory();
/** @var $categoty Mage_Catalog_Model_Categeory */
$categories = $categoty->getChildrenCategories();

$this->getLayer()->getProductCollection()
->addCountToCategories($categories);

$data = array();

foreach ($categories as $category) {
if ($category->getIsActive() && $category->getProductCount()) {
$data[] = array(
'label' => Mage::helper('core')->escapeHtml($category->getName()),
'value' => $category->getId(),
'count' => $category->getProductCount(),
);
}
}

function cmp($a, $b)
{
return strcmp($a["label"], $b["label"]);
}
usort($data, "cmp");
$tags = $this->getLayer()->getStateTags();
$this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
}
return $data;
}


This is the additional part that do the job for us



        function cmp($a, $b)
{
return strcmp($a["label"], $b["label"]);
}
usort($data, "cmp");


This will filter categories in ascending order for layered navigation.



Note:: You are lucky, I have this in extension format. You can use it. This is the github page that holds that extension. Feel free to use it






share|improve this answer
























  • hi many thanks for taking your time to get back to me. I downloaded your extension and uploaded the files to my ftp but navigation still isnt ordering sub categories a-z - is there something else i need to do? thanks

    – rachael
    Sep 1 '14 at 12:02











  • magento version ?

    – Rajeev K Tomy
    Sep 1 '14 at 12:03











  • Magento ver. 1.9.0.1

    – rachael
    Sep 1 '14 at 12:11











  • no way.. I have checked. It is working for me. are you sure you put my extension correctly and please note the extension sort category part of layered navigation, not any other part

    – Rajeev K Tomy
    Sep 1 '14 at 12:14











  • hi yeah i just placed full app directory to my website and cleared cache but still not sorting a-z in layered nav.. perhaps because i have custom theme?

    – rachael
    Sep 1 '14 at 12:16














3












3








3







if you take a look on the template file for layered navigation (cataloglayerview.phtml), you can see that, layered navigation filtering is carried out by this call



<?php $_filters = $this->getFilters() ?>


So take a look on getFilters() method in Mage_Catalog_Block_Layer_View block class.



public function getFilters()
{
$filters = array();
if ($categoryFilter = $this->_getCategoryFilter()) {
$filters[] = $categoryFilter;
}

$filterableAttributes = $this->_getFilterableAttributes();
foreach ($filterableAttributes as $attribute) {
$filters[] = $this->getChild($attribute->getAttributeCode() . '_filter');
}

return $filters;
}


Here you can see that, the method returns an array $filters, which is get filled in two sections. First the array get filled by category filters then it is filled by custom attribute filters. This means that, category filters are available in layered navigation by default



If we dig more and more, we will reach in the model class Mage_Catalog_Model_Layer_Filter_Category, where the actual category filters for layered navigations are carried out. The method that we interested here is _getItemsData()



 protected function _getItemsData()
{
$key = $this->getLayer()->getStateKey().'_SUBCATEGORIES';
$data = $this->getLayer()->getAggregator()->getCacheData($key);

if ($data === null) {
$categoty = $this->getCategory();
/** @var $categoty Mage_Catalog_Model_Categeory */
$categories = $categoty->getChildrenCategories();

$this->getLayer()->getProductCollection()
->addCountToCategories($categories);

$data = array();
foreach ($categories as $category) {
if ($category->getIsActive() && $category->getProductCount()) {
$data[] = array(
'label' => Mage::helper('core')->escapeHtml($category->getName()),
'value' => $category->getId(),
'count' => $category->getProductCount(),
);
}
}
$tags = $this->getLayer()->getStateTags();
$this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
}
return $data;
}


This is where category filters are preparing. The heart of this function is foreach. It uses that loop to load the $data variable(holds an array) which is then return to layered navigation filter. You can again see that, $data holds only 3 parameter of a specific category. They are label,value and children count. So the category section that present in layered navigation actually built up with these three values.



So this is the place that we need to work. By default categories are loading in random, means no filtering is applying there. What we need to do is, we need to sort the $data variable in ascending order.



So rewrite this model as like this.



 protected function _getItemsData()
{
$key = $this->getLayer()->getStateKey().'_SUBCATEGORIES';
$data = $this->getLayer()->getAggregator()->getCacheData($key);

if ($data === null) {
$categoty = $this->getCategory();
/** @var $categoty Mage_Catalog_Model_Categeory */
$categories = $categoty->getChildrenCategories();

$this->getLayer()->getProductCollection()
->addCountToCategories($categories);

$data = array();

foreach ($categories as $category) {
if ($category->getIsActive() && $category->getProductCount()) {
$data[] = array(
'label' => Mage::helper('core')->escapeHtml($category->getName()),
'value' => $category->getId(),
'count' => $category->getProductCount(),
);
}
}

function cmp($a, $b)
{
return strcmp($a["label"], $b["label"]);
}
usort($data, "cmp");
$tags = $this->getLayer()->getStateTags();
$this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
}
return $data;
}


This is the additional part that do the job for us



        function cmp($a, $b)
{
return strcmp($a["label"], $b["label"]);
}
usort($data, "cmp");


This will filter categories in ascending order for layered navigation.



Note:: You are lucky, I have this in extension format. You can use it. This is the github page that holds that extension. Feel free to use it






share|improve this answer













if you take a look on the template file for layered navigation (cataloglayerview.phtml), you can see that, layered navigation filtering is carried out by this call



<?php $_filters = $this->getFilters() ?>


So take a look on getFilters() method in Mage_Catalog_Block_Layer_View block class.



public function getFilters()
{
$filters = array();
if ($categoryFilter = $this->_getCategoryFilter()) {
$filters[] = $categoryFilter;
}

$filterableAttributes = $this->_getFilterableAttributes();
foreach ($filterableAttributes as $attribute) {
$filters[] = $this->getChild($attribute->getAttributeCode() . '_filter');
}

return $filters;
}


Here you can see that, the method returns an array $filters, which is get filled in two sections. First the array get filled by category filters then it is filled by custom attribute filters. This means that, category filters are available in layered navigation by default



If we dig more and more, we will reach in the model class Mage_Catalog_Model_Layer_Filter_Category, where the actual category filters for layered navigations are carried out. The method that we interested here is _getItemsData()



 protected function _getItemsData()
{
$key = $this->getLayer()->getStateKey().'_SUBCATEGORIES';
$data = $this->getLayer()->getAggregator()->getCacheData($key);

if ($data === null) {
$categoty = $this->getCategory();
/** @var $categoty Mage_Catalog_Model_Categeory */
$categories = $categoty->getChildrenCategories();

$this->getLayer()->getProductCollection()
->addCountToCategories($categories);

$data = array();
foreach ($categories as $category) {
if ($category->getIsActive() && $category->getProductCount()) {
$data[] = array(
'label' => Mage::helper('core')->escapeHtml($category->getName()),
'value' => $category->getId(),
'count' => $category->getProductCount(),
);
}
}
$tags = $this->getLayer()->getStateTags();
$this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
}
return $data;
}


This is where category filters are preparing. The heart of this function is foreach. It uses that loop to load the $data variable(holds an array) which is then return to layered navigation filter. You can again see that, $data holds only 3 parameter of a specific category. They are label,value and children count. So the category section that present in layered navigation actually built up with these three values.



So this is the place that we need to work. By default categories are loading in random, means no filtering is applying there. What we need to do is, we need to sort the $data variable in ascending order.



So rewrite this model as like this.



 protected function _getItemsData()
{
$key = $this->getLayer()->getStateKey().'_SUBCATEGORIES';
$data = $this->getLayer()->getAggregator()->getCacheData($key);

if ($data === null) {
$categoty = $this->getCategory();
/** @var $categoty Mage_Catalog_Model_Categeory */
$categories = $categoty->getChildrenCategories();

$this->getLayer()->getProductCollection()
->addCountToCategories($categories);

$data = array();

foreach ($categories as $category) {
if ($category->getIsActive() && $category->getProductCount()) {
$data[] = array(
'label' => Mage::helper('core')->escapeHtml($category->getName()),
'value' => $category->getId(),
'count' => $category->getProductCount(),
);
}
}

function cmp($a, $b)
{
return strcmp($a["label"], $b["label"]);
}
usort($data, "cmp");
$tags = $this->getLayer()->getStateTags();
$this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
}
return $data;
}


This is the additional part that do the job for us



        function cmp($a, $b)
{
return strcmp($a["label"], $b["label"]);
}
usort($data, "cmp");


This will filter categories in ascending order for layered navigation.



Note:: You are lucky, I have this in extension format. You can use it. This is the github page that holds that extension. Feel free to use it







share|improve this answer












share|improve this answer



share|improve this answer










answered Sep 1 '14 at 11:04









Rajeev K TomyRajeev K Tomy

14.6k54589




14.6k54589













  • hi many thanks for taking your time to get back to me. I downloaded your extension and uploaded the files to my ftp but navigation still isnt ordering sub categories a-z - is there something else i need to do? thanks

    – rachael
    Sep 1 '14 at 12:02











  • magento version ?

    – Rajeev K Tomy
    Sep 1 '14 at 12:03











  • Magento ver. 1.9.0.1

    – rachael
    Sep 1 '14 at 12:11











  • no way.. I have checked. It is working for me. are you sure you put my extension correctly and please note the extension sort category part of layered navigation, not any other part

    – Rajeev K Tomy
    Sep 1 '14 at 12:14











  • hi yeah i just placed full app directory to my website and cleared cache but still not sorting a-z in layered nav.. perhaps because i have custom theme?

    – rachael
    Sep 1 '14 at 12:16



















  • hi many thanks for taking your time to get back to me. I downloaded your extension and uploaded the files to my ftp but navigation still isnt ordering sub categories a-z - is there something else i need to do? thanks

    – rachael
    Sep 1 '14 at 12:02











  • magento version ?

    – Rajeev K Tomy
    Sep 1 '14 at 12:03











  • Magento ver. 1.9.0.1

    – rachael
    Sep 1 '14 at 12:11











  • no way.. I have checked. It is working for me. are you sure you put my extension correctly and please note the extension sort category part of layered navigation, not any other part

    – Rajeev K Tomy
    Sep 1 '14 at 12:14











  • hi yeah i just placed full app directory to my website and cleared cache but still not sorting a-z in layered nav.. perhaps because i have custom theme?

    – rachael
    Sep 1 '14 at 12:16

















hi many thanks for taking your time to get back to me. I downloaded your extension and uploaded the files to my ftp but navigation still isnt ordering sub categories a-z - is there something else i need to do? thanks

– rachael
Sep 1 '14 at 12:02





hi many thanks for taking your time to get back to me. I downloaded your extension and uploaded the files to my ftp but navigation still isnt ordering sub categories a-z - is there something else i need to do? thanks

– rachael
Sep 1 '14 at 12:02













magento version ?

– Rajeev K Tomy
Sep 1 '14 at 12:03





magento version ?

– Rajeev K Tomy
Sep 1 '14 at 12:03













Magento ver. 1.9.0.1

– rachael
Sep 1 '14 at 12:11





Magento ver. 1.9.0.1

– rachael
Sep 1 '14 at 12:11













no way.. I have checked. It is working for me. are you sure you put my extension correctly and please note the extension sort category part of layered navigation, not any other part

– Rajeev K Tomy
Sep 1 '14 at 12:14





no way.. I have checked. It is working for me. are you sure you put my extension correctly and please note the extension sort category part of layered navigation, not any other part

– Rajeev K Tomy
Sep 1 '14 at 12:14













hi yeah i just placed full app directory to my website and cleared cache but still not sorting a-z in layered nav.. perhaps because i have custom theme?

– rachael
Sep 1 '14 at 12:16





hi yeah i just placed full app directory to my website and cleared cache but still not sorting a-z in layered nav.. perhaps because i have custom theme?

– rachael
Sep 1 '14 at 12:16


















draft saved

draft discarded




















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f34071%2forder-sub-categories-alphabetically%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

“%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

變成蝙蝠會怎樣? 參考資料 外部連結 导航菜单Thomas Nagel, "What is it like to be a...