Exemple #1
0
 private function getCountByFilterSubSet($filters, $includeAppliedFilters)
 {
     $selectFilter = $this->productFilter->getSelectFilter(!$includeAppliedFilters);
     $selectFilter->removeFieldList();
     $selectFilter->setLimit(0);
     foreach ($filters as $filter) {
         $filter->defineJoin($selectFilter);
         $cond = $filter->getCondition();
         if (!is_object($cond)) {
             continue;
         }
         $expression = 'SUM(' . $cond->getExpressionHandle()->toString() . ')';
         $selectFilter->addField($expression, null, 'cnt_' . $filter->getID());
     }
     $query = ActiveRecordModel::createSelectQuery('Product');
     $query->joinTable('Category', 'Product', 'ID', 'categoryID');
     $query->removeFieldList();
     $query->getFilter()->merge($selectFilter);
     $res = ActiveRecordModel::fetchDataFromDB($query);
     $res = $res[0];
     $ret = array();
     foreach ($res as $key => $value) {
         $ret[substr($key, 4)] = $value;
     }
     return $ret;
 }