When I iterate over category, it is not sorted at all. I can adjust this in the model at getCategories, but I would like adjust this when neccessary and not modify my model to do so. How can I instruct ActiveRecord when it loads categories to add the orderby?
My query ends up like this:
SELECT Product.* FROM Product LEFT JOIN prod_category ON Product.productId = prod_category.productId LEFT JOIN category ON prod_category.categoryId = category.category_id WHERE product.productId = ‘6037’ ORDER BY category.category_path, category_path
When I start iterating over category:
SELECT * FROM category WHERE category_id IN (‘14’, ‘38’, ‘42’, ‘51’)