我需要根据属性“country_of_manufacture”计算/分组/选择产品。像这样
印度 => 10,什里兰卡 => 5,
如何在magento中实现它?
我需要根据属性“country_of_manufacture”计算/分组/选择产品。像这样
印度 => 10,什里兰卡 => 5,
如何在magento中实现它?
$collection = $this->getLoadedProductCollection()
->addAttributeToSelect('*')
->addExpressionAttributeToSelect('total_country_of_manufacture',"COUNT({{entity_id}})",'entity_id')
->groupByAttribute('country_of_manufacture');
计数
Mage::getModel('catalog/product')->getCollection()->groupByAttribute('country_of_manufacture')
->addExpressionAttributeToSelect("cnt_product",'COUNT({{entity_id}})', 'entity_id')
->load();
而不是使用
count($collection)
你可以试试
$collection->getSelect()->count();