Ejemplo n.º 1
0
 public function actionList()
 {
     $catalog = Yii::$app->request->get('catalog');
     $items = Item::getItemsByCategory($catalog);
     $categories = Tree::getCategoriesById($catalog);
     if ($items && $categories) {
         $pages = new Pagination(['totalCount' => $items->count(), 'pageSize' => '3']);
         $items = $items->offset($pages->offset)->limit($pages->limit)->all();
         if ($items) {
             return $this->render('list', ['currentCategory' => Tree::findOne(['id' => $catalog]), 'categories' => $categories, 'items' => $items, 'pages' => $pages]);
         }
     }
     return $this->render('//site/error', ['name' => 'catalog', 'message' => 'There is no product']);
 }