magento override sort order of product list by subcategories

Posted by dardub on Stack Overflow See other posts from Stack Overflow or by dardub
Published on 2010-08-10T23:32:17Z Indexed on 2010/12/23 0:54 UTC
Read the original article Hit count: 191

Filed under:
|

I'm setting up a new store using 1.4.1

I'm trying sort the products in the list by the subcategories they belong to. At the top of list.phtml is

$_productCollection=$this->getLoadedProductCollection();

I tried adding sort filters to that by adding the line

$_productCollection->setOrder('category_ids', 'asc')->setOrder('name', 'asc');

I also tried addAttributeToSort instead of setOrder. This doesn't seem to have any effect. I'm guessing that $_productCollection is not a model I can sort in this manner. I have been digging around trying to find the correct place to apply the sort method without any success.

Can someone tell me the proper place to do this?

© Stack Overflow or respective owner

Related posts about php

Related posts about magento