Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Product::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'image_id' => $this->image_id, 'brand_id' => $this->brand_id, 'mark_id' => $this->mark_id, 'typebeer_id' => $this->typebeer_id, 'size_id' => $this->size_id, 'shop_id' => $this->shop_id, 'price' => $this->price, 'date' => $this->date, 'created' => $this->created]);
     return $dataProvider;
 }
Пример #2
0
 public function actionShowOrder($id = null)
 {
     $model = new Order();
     $model = $model::findOne(['id' => $id]);
     //var_dump($model->product_id);die();
     $products = Product::find()->asArray()->all();
     $listProducts = ArrayHelper::map($products, 'id', 'name');
     $categories = Category::find()->asArray()->all();
     $listCategories = ArrayHelper::map($categories, 'id', 'name');
     $subCategories = SubCategory::find()->asArray()->all();
     $listSubCategories = ArrayHelper::map($subCategories, 'id', 'name');
     return $this->render('showOrder', ['model' => $model, 'listProducts' => $listProducts, 'listCategories' => $listCategories, 'listSubCategories' => $listSubCategories]);
 }
Пример #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Product::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['product_id' => $this->product_id, 'cost' => $this->cost, 'number' => $this->number]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'code', $this->code]);
     return $dataProvider;
 }
Пример #4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     // ленивая загрузка. каждая категория выбирается отдельным запросом
     //$query = Product::find();
     //жадная загрузка. все категории выбираются одним запросом
     $query = Product::find()->with('category');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'price' => $this->price, 'created' => $this->created, 'updated' => $this->updated, 'active' => $this->active, 'category_id' => $this->category_id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'keywords', $this->keywords])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'screen_size', $this->screen_size])->andFilterWhere(['like', 'os', $this->os])->andFilterWhere(['like', 'standart', $this->standart]);
     return $dataProvider;
 }
Пример #5
0
 /**
  * Displays a single Category model.
  * @param string $alias
  * @return mixed
  */
 public function actionView($alias)
 {
     $model = $this->findModel($alias);
     $menu_items_product = Product::getItemsProductMenu($model->id);
     $menu_items_category = Category::getItemsCategoryMenu($model->parent_category_id);
     $sort = new Sort(['attributes' => ['price' => ['asc' => ['price' => SORT_ASC], 'desc' => ['price' => SORT_DESC], 'default' => SORT_DESC]]]);
     $query = Product::find()->where(['active' => 1, 'category_id' => $model->id]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'defaultPageSize' => Yii::$app->params['PageSize']]);
     $items_product = $query->offset($pages->offset)->limit($pages->limit)->orderBy($sort->orders)->all();
     // тут вытягиваем все главные картинки одним запросом
     $arItems = [];
     foreach ($items_product as $value) {
         $arItems[] = $value->id;
     }
     $images = $model->getImagesMain($arItems, 'Product');
     return $this->render('view', ['model' => $model, 'menu_items_product' => $menu_items_product, 'menu_items_category' => $menu_items_category, 'items_product' => $items_product, 'pages' => $pages, 'sort' => $sort, 'images' => $images]);
 }
Пример #6
0
 /**
  * Lists all Product models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Product::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }