-
- colinmollenhour

-
Total Posts: 50
Joined: 2009-05-01
|
Looks like there is a fix in 1.4.1.1 which should be released soon
http://www.magentocommerce.com/bug-tracking/issue?issue=9377
They added a method addExpressionFieldToSelect to the core resource collection model.
/** * Add attribute [removed]SUM, COUNT, etc) * * Example: ('sub_total', 'SUM({{attribute}})', 'revenue') * Example: ('sub_total', 'SUM({{revenue}})', 'revenue') * * For some functions like SUM use groupByAttribute. * * @param string $alias * @param string $expression * @param array $fields * @return Mage_Eav_Model_Entity_Collection_Abstract */ public function addExpressionFieldToSelect($alias, $expression, $fields) { // validate alias if(!is_array($fields)) { $fields = array($fields=>$fields); }
$fullExpression = $expression; foreach($fields as $fieldKey=>$fieldItem) { $fullExpression = str_replace('{{' . $fieldKey . '}}', $fieldItem, $fullExpression); }
$this->getSelect()->columns(array($alias=>$fullExpression));
return $this; }
|