/** * Products. * * @return mixed */ public function actionProducts() { try { $product_id = Yii::$app->request->queryParams["id"]; $product = Products::getProductById($product_id); $model = Categories::getCategories($product['cat_id']); $modelParent = Categories::getCategoriesParent($product['cat_id']); } catch (InvalidParamException $e) { throw new BadRequestHttpException($e->getMessage()); } // breadcrumbs $parent_breadcrumbs = array(); $i = 0; $parent_breadcrumbs[$i] = Categories::getCategoriesParent($modelParent['parent_id']); $parent_cat = NULL; while ($parent_cat = Categories::getCategoriesParent($parent_breadcrumbs[$i]['parent_id'])) { $i++; $parent_breadcrumbs[$i] = $parent_cat; } return $this->render('products', ['model' => $model, 'modelParent' => $modelParent, 'parent_breadcrumbs' => $parent_breadcrumbs, 'product' => $product]); }