/** * Страница категории */ public function actionCat($id) { $query = Product::find()->joinWith('type')->where([ProductType::TableName() . '.cat_id' => $id]); $countQuery = clone $query; $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 20]); $productList = $query->offset($pages->offset)->limit($pages->limit)->with(['type'])->with(['organization'])->asArray()->all(); Product::format($productList); $randProduct = Product::getRandom(1); $randOrg = Organization::getRandom(1); $randSpec = Specialist::getRandom(1, [], ['specTypes']); return $this->render('cat', ['item' => ProductCat::find()->where(['id' => $id])->asArray()->one(), 'productList' => $productList, 'productPages' => $pages, 'randProduct' => $randProduct, 'randOrg' => $randOrg, 'randSpec' => $randSpec]); }