ProductController::actionView PHP Method

actionView() public method

public actionView ( string $name, string $category = null )
$name string Product slug
$category string Product category path
    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]);
    }