getBySlug() public method

public getBySlug ( $slug, array $with = ['producer', 'type.typeAttributes', 'images', 'category', 'variants', 'attributesValues'] ) : mixed
$slug
$with array
return mixed
コード例 #1
0
ファイル: ProductController.php プロジェクト: alextravin/yupe
 /**
  * @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]);
 }
コード例 #2
0
ファイル: ProductController.php プロジェクト: yupe/yupe
 /**
  * @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]);
 }