Ejemplo n.º 1
0
 /**
  * @return array of available attributes in category
  */
 public function getEavAttributes()
 {
     if (is_array($this->_eavAttributes)) {
         return $this->_eavAttributes;
     }
     // Find category types
     $model = new StoreProduct(null);
     $criteria = $model->applyCategories($this->model)->active()->getDbCriteria();
     unset($model);
     $builder = new CDbCommandBuilder(Yii::app()->db->getSchema());
     $criteria->select = 'type_id';
     $criteria->group = 'type_id';
     $criteria->distinct = true;
     $typesUsed = $builder->createFindCommand(StoreProduct::model()->tableName(), $criteria)->queryColumn();
     // Find attributes by type
     $criteria = new CDbCriteria();
     $criteria->addInCondition('types.type_id', $typesUsed);
     $query = StoreAttribute::model()->useInFilter()->with(array('types', 'options'))->findAll($criteria);
     $this->_eavAttributes = array();
     foreach ($query as $attr) {
         $this->_eavAttributes[$attr->name] = $attr;
     }
     return $this->_eavAttributes;
 }