/** * @param $name * @throws CHttpException */ public function actionView($name) { $product = $this->productRepository->getBySlug($name); if (null === $product) { throw new CHttpException(404, Yii::t('StoreModule.catalog', 'Product was not found!')); } $this->render('view', ['product' => $product]); }
/** * @param string $name Product slug * @param string $category Product category path * @throws CHttpException */ public function actionView($name, $category = null) { $product = $this->productRepository->getBySlug($name); if (null === $product || isset($product->category) && $product->category->path !== $category || !isset($product->category) && !is_null($category)) { throw new CHttpException(404, Yii::t('StoreModule.catalog', 'Product was not found!')); } Yii::app()->eventManager->fire(StoreEvents::PRODUCT_OPEN, new ProductOpenEvent($product)); $this->render('view', ['product' => $product]); }