Example #1
0
 public function actionProducts($slug = 'products')
 {
     $filterForm = new GadgetsFilterForm();
     $cat = Catalog::cat($slug);
     if (!$cat) {
         throw new NotFoundHttpException('Shop category not found.');
     }
     $filters = null;
     if ($filterForm->load(Yii::$app->request->get()) && $filterForm->validate()) {
         $filters = $filterForm->parse();
     }
     return $this->render('cat', ['cat' => $cat, 'items' => $cat->items(['pagination' => ['pageSize' => 2], 'filters' => $filters]), 'filterForm' => $filterForm]);
 }
Example #2
0
 public function actionSearch()
 {
     $text = filter_var($_REQUEST['text'], FILTER_SANITIZE_STRING);
     if (Yii::$app->language == 'en') {
         $items = \yii\easyii\modules\catalog\api\Catalog::items(['where' => ['or', ['like', 'title', $text], ['like', 'description', $text]]]);
     } else {
         $slug = 'products';
         $cat = \yii\easyii\modules\catalog\api\Catalog::cat($slug);
         $itemsData = $cat->items();
         foreach ($itemsData as $item) {
             if (strpos($item->title, $text) !== false or strpos($item->description, $text) !== false) {
                 $items[] = $item;
             }
         }
     }
     return $this->render('search', ['text' => $text, 'items' => $items]);
 }
 public function actionViewOnline($slug = null)
 {
     $item = Catalog::get($slug);
     if (!$item) {
         throw new NotFoundHttpException('Item not found.');
     }
     if (\Yii::$app->language == 'en') {
         $product_image = $item->image;
     } else {
         $product_image = $item->image_ar;
     }
     //og tags
     $this->view->params['metatitle'] = $item->og_title;
     $this->view->params['metaimage'] = "http://" . $_SERVER['SERVER_NAME'] . $product_image;
     $this->view->params['metadesc'] = strip_tags($item->og_desc);
     //meta tags
     $this->view->params['meta_title'] = $item->meta_title;
     $this->view->params['meta_keyword'] = strip_tags($item->meta_keyword);
     $this->view->params['meta_description'] = strip_tags($item->meta_desc);
     $cat = Catalog::cat('products');
     return $this->render('viewonline', ['item' => $item, 'addToCartForm' => new \app\models\AddToCartForm(), 'products' => $cat->items()]);
 }
 public function actionViewOnline($slug = null)
 {
     $item = Catalog::get($slug);
     if (!$item) {
         throw new NotFoundHttpException('Item not found.');
     }
     $cat = Catalog::cat('products');
     return $this->render('viewonline', ['item' => $item, 'addToCartForm' => new \app\models\AddToCartForm(), 'products' => $cat->items()]);
 }
 public function actionSuccess()
 {
     $cat = Catalog::cat('products');
     return $this->render('success', array('products' => $cat->items()));
 }