Nikola Ristivojevic
Nikola Ristivojevic

Reputation: 179

Magento product list page - group products by color attribute

I need a help with magento. There are two attributes for creating configurable products, size and color. On the category page where products are listed, I want to display only different colors of products not sizes. I've to group products by color.

I.e. if there is a shirt with colors red, blue, gray, black and for each color there are a sizes M, L, XL (there are 12 simple products), I need to display only 4 products grouped by color.

Thanks in advance

Upvotes: 0

Views: 1428

Answers (1)

miszyman
miszyman

Reputation: 121

I believe your approach for configurable products is wrong - IMHO it should be the whole COLOR as a configurable and then SIZES as SIMPLES so in this case you would have 4 configurables and 3 simples for each ex. SHIRT-RED-M, SHIRT-RED-L, SHIRT-RED-XL as the SKU.

But that's just a suggestion..

As for your original problem - isn't it just this:

$collection =  Mage::getModel('catalog/product')
    ->getCollection()
    ->groupByAttribute('color');

?

Upvotes: 1

Related Questions