Reputation: 2790
I have thhis code on my model:
$categorias = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('status', 1)
->addAttributeToFilter('visibility', 4)
->groupByAttribute('name');
on my backend page this returns all the products values grouped by name, but if i call this on frontend just return 1 value. What's going on? If i remove groupByAttribute line work's fine but don't group. I need group. Ty for help guys
Upvotes: 2
Views: 615
Reputation: 3158
remove your groupByAttribute();
$categorias = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('status', 1)
->addAttributeToFilter('visibility', 4)
//removed ->groupByAttribute('name')
;
$categorias->getSelect()->group('name'); //added
try:
$collection->getSelect()->group($fieldname);
if you want to group by more than one field then:
$categorias->getSelect()->group(array($fieldname1, $fieldname2,...));
Upvotes: 2
Reputation: 2338
Are all the categories enabled on the frontend? It could be they are not and therefore only coming up in backend results.
Pesach
Upvotes: 0