Magento – Is it possible to sort Magento sub categories by alphabetical order by default? NOT with thesql sporadically

categorymagento-communitymodulesql

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.

Best Answer

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.

Related Topic