public function getBySlug($slug, array $with = ['producer', 'type.typeAttributes', 'images', 'category', 'variants', 'attributesValues']) { return Product::model()->published()->with($with)->find('t.slug = :slug', [':slug' => $slug]); }
/** * @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]); }