The last answer here is exactly what I'm looking for, but I want to do it the clean way:
How to sort associated products in a grouped product

Has anybody a solution to achieve this within the grouped.phtml I rather don't want to open up an own module just for this sorting.

I tried $_associatedProducts = $this->getAssociatedProducts($_product)->addAttributeToSort('entity_id', 'ASC');but that doesn't work.

up vote 3 down vote accepted

I tested this on 1.9 and you might put this code into a helper but if you look at the code which gets the associated products it eventually calls Mage_Catalog_Model_Product_Type_Grouped->getAssociatedProducts()

The code below sets the order by price and descending.

$_product = $this->getProduct();
$_grouped =  Mage::getModel('catalog/product_type_grouped');
$_storeFilter = $_grouped->getStoreFilter($_product);
$_status = $_grouped->getStatusFilters($_product);

/** @var Mage_Catalog_Model_Resource_Product_Link_Product_Collection $_associatedProducts */
$_associatedProducts = $_grouped
     ->addAttributeToFilter('status', array('in' => $_status));

// Add custom filtering here
$_associatedProducts->setOrder('price', 'DESC');
  • Works like a charm! Thanks! – Bernhard Prange Jul 28 '15 at 20:32
  • No problem at all. I am glad it helped :) – Colin Murphy Jul 28 '15 at 21:26

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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