Ejemplo n.º 1
0
 public function actionDetail()
 {
     $slug = Yii::$app->request->get('slug');
     if ($cate = ProductCategory::findOne(['slug' => $slug, 'is_active' => 1])) {
         $this->link_canonical = $cate->getLink();
         if (!Redirect::compareUrl($this->link_canonical)) {
             $this->redirect($this->link_canonical);
         }
         Yii::$app->session->set("controllers.product-category.{$cate->id}.detail.offset", 0);
         switch (Yii::$app->request->get('sort')) {
             case 'date_desc':
                 $orderBy = 'created_at desc';
                 break;
             case 'date_asc':
                 $orderBy = 'created_at asc';
                 break;
             case 'price_desc':
                 $orderBy = 'price desc';
                 break;
             case 'price_asc':
                 $orderBy = 'price asc';
                 break;
             case 'rand':
                 $orderBy = 'rand()';
                 break;
             default:
                 $orderBy = 'created_at desc';
         }
         $products = $cate->getProducts(['orderBy' => $orderBy, 'limit' => static::PRODUCTS_LIMIT]);
         $nextProductsNumber = $cate->countProducts(['limit' => static::PRODUCTS_LIMIT, 'offset' => static::PRODUCTS_LIMIT]);
         return $this->render('detail', ['cate' => $cate, 'orderBy' => $orderBy, 'products' => $products, 'nextProductsNumber' => $nextProductsNumber]);
     } else {
         Redirect::go();
     }
 }
Ejemplo n.º 2
0
 public function actionDetail()
 {
     $slug = Yii::$app->request->get('slug');
     if ($model = GeneralInfo::findOne(['slug' => $slug, 'is_active' => 1])) {
         $this->link_canonical = $model->getLink();
         if (!Redirect::compareUrl($this->link_canonical)) {
             $this->redirect($this->link_canonical);
         }
         return $this->render('detail', ['model' => $model]);
     } else {
         Redirect::go();
     }
 }
 public function actionDetail()
 {
     $slug = Yii::$app->request->get('slug');
     if ($coll = ProductCollection::findOne(['slug' => $slug, 'is_active' => 1])) {
         $this->link_canonical = $coll->getLink();
         if (!Redirect::compareUrl($this->link_canonical)) {
             $this->redirect($this->link_canonical);
         }
         Yii::$app->session->set("controllers.product-collection.{$coll->id}.detail.offset", 0);
         switch (Yii::$app->request->get('sort')) {
             case 'date_desc':
                 $orderBy = 'created_at desc';
                 break;
             case 'date_asc':
                 $orderBy = 'created_at asc';
                 break;
             case 'price_desc':
                 $orderBy = 'price desc';
                 break;
             case 'price_asc':
                 $orderBy = 'price asc';
                 break;
             case 'rand':
                 $orderBy = 'rand()';
                 break;
             default:
                 $orderBy = 'created_at desc';
         }
         $products = $coll->getProducts(['orderBy' => $orderBy, 'limit' => static::PRODUCTS_LIMIT]);
         $nextProductsNumber = $coll->countProducts(['limit' => static::PRODUCTS_LIMIT, 'offset' => static::PRODUCTS_LIMIT]);
         if ($this->is_mobile && !$this->is_tablet) {
             $product_collection_banner_suffix = ProductCollection::$banner_resizes['mobile'];
         } else {
             if ($this->is_tablet) {
                 $product_collection_banner_suffix = ProductCollection::$banner_resizes['tablet'];
             } else {
                 $product_collection_banner_suffix = ProductCollection::$banner_resizes['desktop'];
             }
         }
         return $this->render('detail', ['product_collection_banner_suffix' => $product_collection_banner_suffix, 'coll' => $coll, 'orderBy' => $orderBy, 'products' => $products, 'nextProductsNumber' => $nextProductsNumber]);
     } else {
         Redirect::go();
     }
 }
Ejemplo n.º 4
0
 public function actionDetail()
 {
     $slug = Yii::$app->request->get('slug');
     if ($product = Product::findOne(['slug' => $slug, 'is_active' => 1])) {
         $this->link_canonical = $product->getLink();
         if (!Redirect::compareUrl($this->link_canonical)) {
             $this->redirect($this->link_canonical);
         }
         $product_images = ProductImage::find()->where(['product_id' => $product->id])->all();
         if ($this->is_mobile && !$this->is_tablet) {
             $product_image_suffix = ProductImage::$image_resizes['mobile'];
         } else {
             if ($this->is_tablet) {
                 $product_image_suffix = ProductImage::$image_resizes['tablet'];
             } else {
                 $product_image_suffix = ProductImage::$image_resizes['desktop'];
             }
         }
         return $this->render('detail', ['product' => $product, 'product_images' => $product_images, 'product_image_suffix' => $product_image_suffix]);
     } else {
         Redirect::go();
     }
 }