Пример #1
0
 public function actionImagine()
 {
     $product = ProductRecord::find()->lang()->one();
     echo Html::img($product->image->source);
     echo Html::img($product->imageSrc('200x200', \yii\image\drivers\Image::CROP));
     echo Html::img($product->imageSrc('100x200', \yii\image\drivers\Image::CROP));
     echo Html::img($product->imageSrc('500x200'));
 }
Пример #2
0
 public function actionView($path, $id, $lang = null)
 {
     $product = ProductRecord::find()->lang($lang)->andWhere(['id' => $id])->one();
     $category = $product->parent->findByFullPath($path);
     if (!$product && !$category) {
         throw new HttpException(404, 'Товар не найден');
     }
     if (\Yii::$app->request->isAjax) {
         return $this->renderAjax('view', ['product' => $product]);
     }
     return $this->render('view', ['product' => $product]);
 }
Пример #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProductRecord::find()->lang();
     $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, 'categoryId' => $this->categoryId]);
     $query->andFilterWhere(['like', 'lang', $this->lang])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'metaKeywords', $this->metaKeywords])->andFilterWhere(['like', 'metaDescription', $this->metaDescription]);
     return $dataProvider;
 }
 public function actionStepOne($id)
 {
     /** @var $model ProductRecord*/
     $model = ProductRecord::findOne($id);
     if (!$model) {
         throw new HttpException(404, Language::t('reservation', 'Аппартаменты не найдены!'));
     }
     $formModel = new BookingForm();
     $formModel->productId = $id;
     if (\Yii::$app->request->isAjax && $formModel->load($_POST)) {
         \Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($formModel);
     }
     if ($formModel->load($_POST) && $formModel->send()) {
         return $this->redirect($this->goBack());
     }
     return $this->renderAjax('stepOne', ['model' => $model, 'formModel' => $formModel]);
 }
Пример #5
0
 public function getProducts($path, $limit = 12, $lang = 'ru')
 {
     $categoryModel = new CategoryRecord();
     $category = $categoryModel->findByFullPath($path, $limit);
     if (!$category) {
         return [];
     }
     $categoryList = $category->childrens();
     $categoryIds[] = $category->id;
     foreach ($categoryList as $categoryItem) {
         $categoryIds[] = $categoryItem->id;
     }
     $productList = ProductRecord::find()->lang($lang)->andWhere(['categoryId' => $categoryIds])->all();
     return $productList ? $productList : [];
 }
Пример #6
0
 public function getProduct()
 {
     return $this->hasOne(ProductRecord::className(), ['id' => 'productId'])->andWhere(['lang' => \Yii::$app->language]);
 }
Пример #7
0
 public function getProduct()
 {
     return ProductRecord::find()->lang()->andWhere(['id' => $this->productId])->one();
 }