0

I have a category with about 2500 products and all of them are grouped products with some associates. In the category I have a lot of them with only one associated but I need to sort the category, showing first, those with more than one associated product.

For example: I have three grouped products with: 5, 4 and 3 associated products respectively and I want to sort the category like this:

GroupedProduct1(5 associated)

GroupedProduct2(4 associated)

GroupedProduct3(3 associated)

Anybody knows any reference or method to do that? Thanks very much for advance.

1 Answer 1

0

I think there are a few ways to do this. One way is this.

  1. Create an attribute that holds an integer and doesn't show on the frontend. Name this "Number of Associated/Child Products".

  2. Create an observer to hook onto the catalog_product_save_before event to save the number of child products for grouped products only.

  3. Rewrite Mage_Catalog_Block_Product_List::_getProductCollection to add an ORDER BY clause using your custom attribute. $collection->getSelect()->__toString()->order('e.my_attribute ASC') (or DESC) is the syntax.

This will require you to go through all of your grouped products and save them without once to populate the custom attribute. This in effect acts as a global position value as opposed to the category product positions, which apply to specific categories. I've never tried this, but it should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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