cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting product collection based on sizes available

Sorting product collection based on sizes available

My store contains all configurable products. Each configurable product contains five associated products for sizes. Sizes available are XS, S, M, L, XL. The client wants the products to be sorted based on the available sizes, i.e suppose a product has all the five sizes available will come in the list before a product which has only four sizes available. Similarly, a product with four sizes available will come in the list before a product with only three sizes available. Finally, the product which has only one size available will come last in the list.

Any idea how to achieve this? Thanks.