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?

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.

  • Keep in mind I am talking about the search results filters and not the category navigation. – Jason McCreary Sep 2 '15 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 – Joe Constant Sep 2 '15 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.

  • Op specifically asked for another way to do it than what you suggest. – Joe Constant Sep 2 '15 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. – Adarsh Khatri Sep 2 '15 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. – Joe Constant Sep 2 '15 at 2:18
  • Keep in mind I am talking about the search results filters and not the category navigation. – Jason McCreary Sep 2 '15 at 12:21
  • Sure, I believe it works for your search results as well. Give it a try. – Adarsh Khatri Sep 2 '15 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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