I have this code for getting a list of category IDs:
$categoryModel = Mage::getModel('catalog/category')->load($id); $allCategoryIds = $category->getResource()->getChildren($category, true);
This gives me a nice little array with a list of category IDs, like this:
Array( => 10,  => 11,  => 3,  => 4,  => 5,  => 6,  => 7,  => 14,  => 17,  => 18);
What I want to do is order this array by the position these categories appear in the Admin Panel.
To begin with I looked into these solutions:
- how to sort categories as they are shown in admin?
- In Magento how do I get the listing of categories in the order you see in the admin area?
However both of these solutions end up using an entire collection, and then sorting that collection. To get my array sorted as I would like, I would have to iterate through the entire collection and use that to re-order my array. This seems wrong / wasteful to me (please correct me if I am wrong here).
I am wondering if an SQL call be made to the database to get a simple array of Category IDs and their position in the Admin Panel? Would this be quicker and more efficient than using Magento's system? I would rather use Magento's system if possible, but not if it involves iterating over several large objects (this page is already doing a lot of work).
So my question is:
What is the easiest and most efficient way of getting just an array of category IDs (like above), but in order of of they are displayed in the Admin Panel?