2

I want to sort the category filters alphabetically by name on my search results page.

enter image description here

Most answers suggest setting the position for every category. However, this seems rather manual. Is there another way to sort the category filters? Ideally through an option?

2 Answers 2

1

You can't do it through an option, but you could do it through code.

You would need to get access to the category collection by extending the Mage_Catalog_Block_Navigation class and overriding the getCurrentChildCategories() function to call setOrder('name') on $this->_currentChildCategories prior to returning it.

2
  • Keep in mind I am talking about the search results filters and not the category navigation. Sep 2, 2015 at 12:21
  • Ah, I have the wrong block listed there, but the concept is right. I'll find the correct block later today and update the answer Sep 2, 2015 at 12:35
0

You can do it by editing/extending core code. However, I always like to avoid editing/extending core code.

You can go to catalog > category > manage categories section and re-adjust by pulling down/up as needed manually.

This will sort your categories. I know this is time consuming, but this is needed only once. After this, if you add any new category in future, just need to re-adjust that new one only.

Hope this helps.

5
  • Op specifically asked for another way to do it than what you suggest. Sep 2, 2015 at 2:13
  • Sure he did @JoeConstant, however you should always show them better way and magento way. There are always diff ways of doing things. Hope you understand that. Cheers. Sep 2, 2015 at 2:14
  • I don't disagree with the approach (manually sorting it once now). However, there is nothing wrong with wanting to do it another way. Sep 2, 2015 at 2:18
  • Keep in mind I am talking about the search results filters and not the category navigation. Sep 2, 2015 at 12:21
  • Sure, I believe it works for your search results as well. Give it a try. Sep 2, 2015 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.