2

Is it possible to sort magento sub categories automatically by alphabetical order? Currently the only way to do so in Magento, is to re-arrange them manually from the manage categories page in admin, which is very time consuming, particularly when like us you have over 1000 sub categories!! I've seen a few posts about hard coding the sql on the navigation.php page, but would prefer to create a module to do this over riding the core files. Any ideas?

This isn't a duplicate of the other question here:

Categories - how to display in alphabetical order? (Programmatically)

Our question is how can Magento automatically continually ensure categories are sorted in alphabetically. NOT running an SQL query every now and then to sort all categories live at that point. This would require a cron job to be setup to have it continually runnning or would have to be regularly manually run.

Our question is can the core magento files for creating the cateogry page layout be overridden by files sorting the sub categories automatically?

For our particular instance, we wouldn't want the top level categories sorted alphabetically. Just all sub categories underneath them. I hope this makes sense? There are numerous posts about how to do this with sql sporadically, but no actual proper solution.

6
  • I'm looking at ways of doing this now and it's different depending on the use of flat tables or EAV, both are fairly intensive. I would consider one of the existing suggestions to update the position automatically, if not by cron then on the event of a category being saved. Commented Oct 7, 2013 at 19:36
  • To clarify, You are trying to override the sorting of sub-cats on page load?
    – SH-
    Commented Oct 7, 2013 at 23:49
  • @SH Yes, really just looking for all sub categories to automatically be sorted by name alphabetically. I'm not certain what this requires. Initially I thought it would just be a simple "sort by name" query in the navigation.php but as clockworkgeek has already worked out as well, it's not that simple and is quite complex. Any ideas on how to override the sorting of sub-cats?
    – MagentoMac
    Commented Oct 8, 2013 at 9:03
  • 1
    How about adding the code in the link you mentioned magento.stackexchange.com/a/5665/146 in an observer for the catalog_category_save_after event? You can only call the function specified in there for the parent category of the category that is being saved. Then it is not important where you add the category from the UI, it will always be set in the correct position determined by the alphabetical order.
    – Marius
    Commented Jan 29, 2014 at 9:31
  • 1
    @DavidManners. I added it as an answer.
    – Marius
    Commented May 19, 2014 at 19:50

1 Answer 1

1

As specified in the comments, you can try adding the code in the link you mentioned in an observer for the catalog_category_save_after event.
You can only call the function specified in there for the parent category of the category that is being saved. Then it is not important where you add the category from the UI, it will always be set in the correct position determined by the alphabetical order.

Your Answer

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

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