/**
  * Count products by attribute and option
  * @param StoreAttribute $attribute
  * @param string $option option id to search
  * @todo Optimize attributes merging
  * @return string
  */
 public function countAttributeProducts($attribute, $option)
 {
     $model = new StoreProduct(null);
     $model->attachBehaviors($model->behaviors());
     $model->active()->applyCategories($this->model)->applyMinPrice($this->convertCurrency(Yii::app()->request->getQuery('min_price')))->applyMaxPrice($this->convertCurrency(Yii::app()->request->getQuery('max_price')));
     if (Yii::app()->request->getParam('manufacturer')) {
         $model->applyManufacturers(explode(';', Yii::app()->request->getParam('manufacturer')));
     }
     $data = array($attribute->name => $option->id);
     $current = $this->getOwner()->activeAttributes;
     $newData = array();
     foreach ($current as $key => $row) {
         if (!isset($newData[$key])) {
             $newData[$key] = array();
         }
         if (is_array($row)) {
             foreach ($row as $v) {
                 $newData[$key][] = $v;
             }
         } else {
             $newData[$key][] = $row;
         }
     }
     $newData[$attribute->name][] = $option->id;
     return $model->withEavAttributes($newData)->count();
 }