I am trying to display the search result sorted by attribute_set_id.

I want to display them with the title as the name of the first attribute_set and then all the products that belong to attribute_set_id 1 and then title of attribute_set 2 and then the products in attribute set 2.

Any one got an idea on how i can make this happened?

I have tried to sort the result list by the following code

<?php $_productCollection = clone $this->getLoadedProductCollection();

    ->addAttributeToSort('attribute_set_id', 'DESC')
  • Please tell me, that the code you showed us are not in any template. Wherever it is, it looks like you are loading the collection, then clears it, add the attributes and sorting and reloads it. Adding all attributes is a bad idea and loading the collection twice is a bad idea too. Nov 10 '13 at 22:42

Try to use ->setOrder('attribute_set_id', 'DESC') because ->addAttributeToSort applies to EAV types only

setOrder($field, $direction = self::SORT_ORDER_DESC) is from Varien/Data/Collection.php so should work fine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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