I have a few categories: guys, ladies, men, women and offers.
Every product is assigned to guys, ladies, men OR women categories.
And some products are assigned to "offers" category.
I need to retrieve every "offers" products but sort by the others categories, I mean:
OFFERS
-> guys products
-> ladies products
-> men products
-> women products
$collection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSort('category_ids', 'ASC')
->addAttributeToSelect(array('name', 'sku', 'status', 'visibility', 'is_saleable'));
foreach ($_productCollection as $_product) {
echo "<!-- " . $_product->getName() . '-->';
}
Right now I am getting the products to display by the category "offers", but this products cames ordered by name attribute and I need those products sorted by category before name.
How can I achieve this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…