Ejemplo n.º 1
0
 public function items($options = [])
 {
     if (!$this->_items) {
         $this->_items = [];
         $query = Item::find()->with('seo')->where(['category_id' => $this->id])->status(Item::STATUS_ON);
         if (!empty($options['where'])) {
             $query->andFilterWhere($options['where']);
         }
         if (!empty($options['orderBy'])) {
             $query->orderBy($options['orderBy']);
         } else {
             $query->sortDate();
         }
         if (!empty($options['filters'])) {
             $query = Catalog::applyFilters($options['filters'], $query);
         }
         $this->_adp = new ActiveDataProvider(['query' => $query, 'pagination' => !empty($options['pagination']) ? $options['pagination'] : []]);
         foreach ($this->_adp->models as $model) {
             $this->_items[] = new ItemObject($model);
         }
     }
     return $this->_items;
 }