From 4428da8cca9d3e02b2c2515947f37fcbe199b978 Mon Sep 17 00:00:00 2001
From: yarik
Date: Fri, 28 Oct 2016 18:53:12 +0300
Subject: [PATCH] Almost all database finish.
---
backend/controllers/OrderController.php | 4 +++-
backend/controllers/SeoCategoryController.php | 6 +++---
backend/controllers/SeoController.php | 80 +++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------
backend/controllers/SeoDynamicController.php | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------
backend/controllers/ServiceController.php | 74 ++++++++++++++++++++++++++++++++++++++++++++++----------------------------
backend/controllers/SliderController.php | 270 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------
backend/controllers/SliderImageController.php | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------
backend/models/OrderProducts.php | 2 +-
backend/views/seo-category/index.php | 60 ++++++++++++++++++++++++++++++++++--------------------------
backend/views/seo-category/update.php | 2 +-
backend/views/seo-dynamic/create.php | 13 ++++++++-----
backend/views/seo-dynamic/index.php | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------
backend/views/seo-dynamic/update.php | 27 +++++++++++++++++----------
backend/views/seo-dynamic/view.php | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------
backend/views/seo/index.php | 60 +++++++++++++++++++++++++++++++-----------------------------
backend/views/seo/update.php | 23 +++++++++++++++--------
backend/views/seo/view.php | 60 +++++++++++++++++++++++++++++++++++-------------------------
backend/views/service/index.php | 28 +++++++++++++++-------------
backend/views/service/update.php | 25 ++++++++++++++++---------
backend/views/service/view.php | 54 ++++++++++++++++++++++++++++++++----------------------
backend/views/slider-image/index.php | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------
backend/views/slider-image/update.php | 55 ++++++++++++++++++++++++++++++++++---------------------
backend/views/slider-image/view.php | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------
backend/views/slider/index.php | 86 +++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------
common/models/Basket.php | 4 ++--
common/models/Order.php | 4 ++--
common/models/OrderProduct.php | 2 +-
common/models/Seo.php | 7 ++++---
common/models/SeoCategory.php | 11 ++++++-----
common/models/SeoCategoryLang.php | 7 ++++---
common/models/SeoCategorySearch.php | 64 ++++++++++++++++++++++++++++++++++++----------------------------
common/models/SeoDynamic.php | 9 +++++----
common/models/SeoDynamicLang.php | 23 ++++++++++++-----------
common/models/SeoDynamicSearch.php | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------
common/models/SeoLang.php | 17 +++++++++--------
common/models/SeoSearch.php | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------
common/models/Service.php | 5 +++--
common/models/ServiceLang.php | 21 +++++++++++----------
common/models/ServiceSearch.php | 24 ++++++++++++++----------
common/models/Slider.php | 41 +++++++++++++++++++++++------------------
common/models/SliderImage.php | 19 ++++++++++---------
common/models/SliderImageLang.php | 5 +++--
common/models/SliderImageSearch.php | 38 ++++++++++++++++++++++----------------
common/models/SliderSearch.php | 34 ++++++++++++++++++++--------------
common/modules/product/controllers/ManageController.php | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------
common/modules/product/controllers/ProductUnitController.php | 80 +++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------
common/modules/product/controllers/VariantController.php | 192 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------
common/modules/product/helpers/ProductHelper.php | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------
common/modules/product/models/Category.php | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------
common/modules/product/models/Export.php | 45 ++++++++++++++++++++++++++++-----------------
common/modules/product/models/Import.php | 331 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------
common/modules/product/models/Product.php | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------
common/modules/product/models/ProductImage.php | 7 ++++---
common/modules/product/models/ProductSearch.php | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------
common/modules/product/models/ProductStock.php | 26 +++++++++-----------------
common/modules/product/models/ProductUnit.php | 11 ++++++-----
common/modules/product/models/ProductUnitLang.php | 7 ++++---
common/modules/product/models/ProductUnitSearch.php | 50 ++++++++++++++++++++++++++++----------------------
common/modules/product/models/ProductVariant.php | 55 +++++++++++++++++++++++++------------------------------
common/modules/product/models/ProductVariantLang.php | 7 ++++---
common/modules/product/models/ProductVariantOption.php | 5 +++--
common/modules/product/models/ProductVariantSearch.php | 84 ++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------
common/modules/product/models/Stock.php | 26 ++++++++++++++++++++++----
common/modules/product/views/manage/_form.php | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------
common/modules/product/views/manage/index.php | 18 +++++++++---------
common/modules/product/views/manage/view.php | 6 +++---
common/modules/product/views/product-unit/index.php | 40 +++++++++++++++++++++-------------------
common/modules/product/views/product-unit/update.php | 2 +-
common/modules/product/views/product-unit/view.php | 54 ++++++++++++++++++++++++++++++++----------------------
common/modules/product/views/variant/_form.php | 2 +-
common/modules/product/views/variant/index.php | 8 ++++----
common/modules/product/views/variant/update.php | 2 +-
common/modules/product/views/variant/view.php | 6 +++---
common/modules/product/widgets/views/product_smart.php | 46 +++++++++++++++++++++++++++++-----------------
common/modules/rubrication/models/TaxOption.php | 2 +-
common/widgets/views/basket_modal.php | 6 +++---
console/migrations/m160929_173535_create_product_unit_lang_table.php | 52 ++++++++++++++++++++++++++++++++++++++--------------
console/migrations/m160929_175821_create_product_variant_lang_table.php | 50 +++++++++++++++++++++++++++++++++++++-------------
console/migrations/m160930_100954_create_seo_lang_table.php | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------
console/migrations/m160930_133757_create_service_lang_table.php | 46 +++++++++++++++++++++++++++-------------------
console/migrations/m160930_142752_create_slider_image_lang_table.php | 50 +++++++++++++++++++++++++++++++++++++-------------
console/migrations/m161011_104931_create_stock_lang_table.php | 74 +++++++++++++++++++++++++++++++++++++++++---------------------------------
frontend/web/js/artbox_basket.js | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------
83 files changed, 2831 insertions(+), 1993 deletions(-)
diff --git a/backend/controllers/OrderController.php b/backend/controllers/OrderController.php
index 5464b1d..825ac17 100755
--- a/backend/controllers/OrderController.php
+++ b/backend/controllers/OrderController.php
@@ -113,7 +113,9 @@
{
$model = new orderProduct();
if ($model->load(Yii::$app->request->post())) {
-
+ /**
+ * @var ProductVariant $modelMod
+ */
if (!$modelMod = ProductVariant::find()
->with([ 'product' ])
->where([ 'sku' => $model->sku ])
diff --git a/backend/controllers/SeoCategoryController.php b/backend/controllers/SeoCategoryController.php
index d749ea0..13345e9 100755
--- a/backend/controllers/SeoCategoryController.php
+++ b/backend/controllers/SeoCategoryController.php
@@ -73,7 +73,7 @@
if($model->save() && $model->transactionStatus) {
return $this->redirect([
'view',
- 'id' => $model->seo_category_id,
+ 'id' => $model->id,
]);
}
}
@@ -100,7 +100,7 @@
if($model->save() && $model->transactionStatus) {
return $this->redirect([
'view',
- 'id' => $model->seo_category_id,
+ 'id' => $model->id,
]);
}
}
@@ -138,7 +138,7 @@
protected function findModel($id)
{
if(( $model = SeoCategory::find()
- ->where([ 'seo_category_id' => $id ])
+ ->where([ 'id' => $id ])
->with('lang')
->one() ) !== NULL
) {
diff --git a/backend/controllers/SeoController.php b/backend/controllers/SeoController.php
index dd61108..37e7b80 100755
--- a/backend/controllers/SeoController.php
+++ b/backend/controllers/SeoController.php
@@ -45,6 +45,7 @@
/**
* Lists all Seo models.
+ *
* @return mixed
*/
public function actionIndex()
@@ -52,10 +53,13 @@
$searchModel = new SeoSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
- return $this->render('index', [
- 'searchModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- ]);
+ return $this->render(
+ 'index',
+ [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ ]
+ );
}
/**
@@ -67,14 +71,18 @@
*/
public function actionView($id)
{
- return $this->render('view', [
- 'model' => $this->findModel($id),
- ]);
+ return $this->render(
+ 'view',
+ [
+ 'model' => $this->findModel($id),
+ ]
+ );
}
/**
* Creates a new Seo model.
* If creation is successful, the browser will be redirected to the 'view' page.
+ *
* @return mixed
*/
public function actionCreate()
@@ -82,19 +90,24 @@
$model = new Seo();
$model->generateLangs();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
$model->loadLangs(\Yii::$app->request);
- if($model->save() && $model->transactionStatus) {
- return $this->redirect([
- 'view',
- 'id' => $model->seo_id,
- ]);
+ if ($model->save() && $model->transactionStatus) {
+ return $this->redirect(
+ [
+ 'view',
+ 'id' => $model->id,
+ ]
+ );
}
}
- return $this->render('create', [
- 'model' => $model,
- 'modelLangs' => $model->modelLangs,
- ]);
+ return $this->render(
+ 'create',
+ [
+ 'model' => $model,
+ 'modelLangs' => $model->modelLangs,
+ ]
+ );
}
/**
@@ -109,19 +122,24 @@
{
$model = $this->findModel($id);
$model->generateLangs();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
$model->loadLangs(\Yii::$app->request);
- if($model->save() && $model->transactionStatus) {
- return $this->redirect([
- 'view',
- 'id' => $model->seo_id,
- ]);
+ if ($model->save() && $model->transactionStatus) {
+ return $this->redirect(
+ [
+ 'view',
+ 'id' => $model->id,
+ ]
+ );
}
}
- return $this->render('update', [
- 'model' => $model,
- 'modelLangs' => $model->modelLangs,
- ]);
+ return $this->render(
+ 'update',
+ [
+ 'model' => $model,
+ 'modelLangs' => $model->modelLangs,
+ ]
+ );
}
/**
@@ -151,10 +169,10 @@
*/
protected function findModel($id)
{
- if(( $model = Seo::find()
- ->where([ 'seo_id' => $id ])
- ->with('lang')
- ->one() ) !== NULL
+ if (( $model = Seo::find()
+ ->where([ 'id' => $id ])
+ ->with('lang')
+ ->one() ) !== null
) {
return $model;
} else {
diff --git a/backend/controllers/SeoDynamicController.php b/backend/controllers/SeoDynamicController.php
index 5b67b28..ee6f6d0 100755
--- a/backend/controllers/SeoDynamicController.php
+++ b/backend/controllers/SeoDynamicController.php
@@ -57,11 +57,14 @@
$searchModel = new SeoDynamicSearch();
$dataProvider = $searchModel->search($seo_category_id, Yii::$app->request->queryParams);
- return $this->render('index', [
- 'searchModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- 'seo_category' => $seo_category,
- ]);
+ return $this->render(
+ 'index',
+ [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ 'seo_category' => $seo_category,
+ ]
+ );
}
/**
@@ -75,10 +78,13 @@
public function actionView($seo_category_id, $id)
{
$seo_category = $this->findCategory($seo_category_id);
- return $this->render('view', [
- 'model' => $this->findModel($id),
- 'seo_category' => $seo_category,
- ]);
+ return $this->render(
+ 'view',
+ [
+ 'model' => $this->findModel($id),
+ 'seo_category' => $seo_category,
+ ]
+ );
}
/**
@@ -94,21 +100,26 @@
$seo_category = $this->findCategory($seo_category_id);
$model = new SeoDynamic();
$model->generateLangs();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
$model->loadLangs(\Yii::$app->request);
$model->seo_category_id = $seo_category_id;
- if($model->save() && $model->transactionStatus) {
- return $this->redirect([
- 'index',
- 'seo_category_id' => $seo_category_id,
- ]);
+ if ($model->save() && $model->transactionStatus) {
+ return $this->redirect(
+ [
+ 'index',
+ 'seo_category_id' => $seo_category_id,
+ ]
+ );
}
}
- return $this->render('create', [
- 'model' => $model,
- 'modelLangs' => $model->modelLangs,
- 'seo_category' => $seo_category,
- ]);
+ return $this->render(
+ 'create',
+ [
+ 'model' => $model,
+ 'modelLangs' => $model->modelLangs,
+ 'seo_category' => $seo_category,
+ ]
+ );
}
/**
@@ -125,20 +136,25 @@
$seo_category = $this->findCategory($seo_category_id);
$model = $this->findModel($id);
$model->generateLangs();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
$model->loadLangs(\Yii::$app->request);
- if($model->save() && $model->transactionStatus) {
- return $this->redirect([
- 'index',
- 'seo_category_id' => $seo_category_id,
- ]);
+ if ($model->save() && $model->transactionStatus) {
+ return $this->redirect(
+ [
+ 'index',
+ 'seo_category_id' => $seo_category_id,
+ ]
+ );
}
}
- return $this->render('update', [
- 'model' => $model,
- 'modelLangs' => $model->modelLangs,
- 'seo_category' => $seo_category,
- ]);
+ return $this->render(
+ 'update',
+ [
+ 'model' => $model,
+ 'modelLangs' => $model->modelLangs,
+ 'seo_category' => $seo_category,
+ ]
+ );
}
/**
@@ -155,10 +171,12 @@
$this->findModel($id)
->delete();
- return $this->redirect([
- 'index',
- 'seo_category_id' => $seo_category_id,
- ]);
+ return $this->redirect(
+ [
+ 'index',
+ 'seo_category_id' => $seo_category_id,
+ ]
+ );
}
/**
@@ -172,10 +190,10 @@
*/
protected function findModel($id)
{
- if(( $model = SeoDynamic::find()
- ->where([ 'seo_dynamic_id' => $id ])
- ->with('lang')
- ->one() ) !== NULL
+ if (( $model = SeoDynamic::find()
+ ->where([ 'id' => $id ])
+ ->with('lang')
+ ->one() ) !== null
) {
return $model;
} else {
@@ -185,10 +203,10 @@
protected function findCategory($id)
{
- if(( $model = SeoCategory::find()
- ->where([ 'seo_category_id' => $id ])
- ->with('lang')
- ->one() ) !== NULL
+ if (( $model = SeoCategory::find()
+ ->where([ 'id' => $id ])
+ ->with('lang')
+ ->one() ) !== null
) {
return $model;
} else {
diff --git a/backend/controllers/ServiceController.php b/backend/controllers/ServiceController.php
index de422c7..b375478 100755
--- a/backend/controllers/ServiceController.php
+++ b/backend/controllers/ServiceController.php
@@ -47,6 +47,7 @@
/**
* Lists all Service models.
+ *
* @return mixed
*/
public function actionIndex()
@@ -54,10 +55,13 @@
$searchModel = new ServiceSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
- return $this->render('index', [
- 'searchModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- ]);
+ return $this->render(
+ 'index',
+ [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ ]
+ );
}
/**
@@ -69,33 +73,42 @@
*/
public function actionView($id)
{
- return $this->render('view', [
- 'model' => $this->findModel($id),
- ]);
+ return $this->render(
+ 'view',
+ [
+ 'model' => $this->findModel($id),
+ ]
+ );
}
/**
* Creates a new Service model.
* If creation is successful, the browser will be redirected to the 'view' page.
+ *
* @return mixed
*/
public function actionCreate()
{
$model = new Service();
$model->generateLangs();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
$model->loadLangs(\Yii::$app->request);
- if($model->save() && $model->transactionStatus) {
- return $this->redirect([
- 'view',
- 'id' => $model->service_id,
- ]);
+ if ($model->save() && $model->transactionStatus) {
+ return $this->redirect(
+ [
+ 'view',
+ 'id' => $model->id,
+ ]
+ );
}
}
- return $this->render('create', [
- 'model' => $model,
- 'modelLangs' => $model->modelLangs,
- ]);
+ return $this->render(
+ 'create',
+ [
+ 'model' => $model,
+ 'modelLangs' => $model->modelLangs,
+ ]
+ );
}
/**
@@ -111,19 +124,24 @@
$model = $this->findModel($id);
$model->generateLangs();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
$model->loadLangs(\Yii::$app->request);
- if($model->save() && $model->transactionStatus) {
- return $this->redirect([
- 'view',
- 'id' => $model->service_id,
- ]);
+ if ($model->save() && $model->transactionStatus) {
+ return $this->redirect(
+ [
+ 'view',
+ 'id' => $model->id,
+ ]
+ );
}
}
- return $this->render('update', [
- 'model' => $model,
- 'modelLangs' => $model->modelLangs,
- ]);
+ return $this->render(
+ 'update',
+ [
+ 'model' => $model,
+ 'modelLangs' => $model->modelLangs,
+ ]
+ );
}
/**
@@ -153,7 +171,7 @@
*/
protected function findModel($id)
{
- if(( $model = Service::findOne($id) ) !== NULL) {
+ if (( $model = Service::findOne($id) ) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
diff --git a/backend/controllers/SliderController.php b/backend/controllers/SliderController.php
index 22c3cbf..848a690 100755
--- a/backend/controllers/SliderController.php
+++ b/backend/controllers/SliderController.php
@@ -1,132 +1,162 @@
[
- 'class' => AccessBehavior::className(),
- 'rules' =>
- ['site' =>
- [
+ /**
+ * @inheritdoc
+ */
+ public function behaviors()
+ {
+ return [
+ 'access' => [
+ 'class' => AccessBehavior::className(),
+ 'rules' => [
+ 'site' => [
[
- 'actions' => ['login', 'error'],
- 'allow' => true,
- ]
- ]
- ]
- ],
- 'verbs' => [
- 'class' => VerbFilter::className(),
- 'actions' => [
- 'delete' => ['POST'],
+ 'actions' => [
+ 'login',
+ 'error',
+ ],
+ 'allow' => true,
+ ],
+ ],
+ ],
],
- ],
- ];
- }
-
- /**
- * Lists all Slider models.
- * @return mixed
- */
- public function actionIndex()
- {
- $searchModel = new SliderSearch();
- $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+ 'verbs' => [
+ 'class' => VerbFilter::className(),
+ 'actions' => [
+ 'delete' => [ 'POST' ],
+ ],
+ ],
+ ];
+ }
+
/**
- * @var ActiveQuery $query
+ * Lists all Slider models.
+ *
+ * @return mixed
*/
- $query = $dataProvider->query;
- $query->with('sliderImage');
-
- return $this->render('index', [
- 'searchModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- ]);
- }
-
- /**
- * Creates a new Slider model.
- * If creation is successful, the browser will be redirected to the 'view' page.
- * @return mixed
- */
- public function actionCreate()
- {
- $model = new Slider();
-
- if ($model->load(Yii::$app->request->post()) && $model->save()) {
- return $this->redirect(['view', 'id' => $model->slider_id]);
- } else {
-
-
- return $this->render('create', [
- 'model' => $model,
- ]);
+ public function actionIndex()
+ {
+ $searchModel = new SliderSearch();
+ $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+ /**
+ * @var ActiveQuery $query
+ */
+ $query = $dataProvider->query;
+ $query->with('sliderImage');
+
+ return $this->render(
+ 'index',
+ [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ ]
+ );
}
- }
-
- /**
- * Updates an existing Slider model.
- * If update is successful, the browser will be redirected to the 'view' page.
- * @param integer $id
- * @return mixed
- */
- public function actionUpdate($id)
- {
- $model = $this->findModel($id);
-
- if ($model->load(Yii::$app->request->post()) && $model->save()) {
- return $this->redirect(['view', 'id' => $model->slider_id]);
- } else {
- return $this->render('update', [
- 'model' => $model,
- ]);
+
+ /**
+ * Creates a new Slider model.
+ * If creation is successful, the browser will be redirected to the 'view' page.
+ *
+ * @return mixed
+ */
+ public function actionCreate()
+ {
+ $model = new Slider();
+
+ if ($model->load(Yii::$app->request->post()) && $model->save()) {
+ return $this->redirect(
+ [
+ 'view',
+ 'id' => $model->id,
+ ]
+ );
+ } else {
+
+ return $this->render(
+ 'create',
+ [
+ 'model' => $model,
+ ]
+ );
+ }
}
- }
-
- /**
- * Deletes an existing Slider model.
- * If deletion is successful, the browser will be redirected to the 'index' page.
- * @param integer $id
- * @return mixed
- */
- public function actionDelete($id)
- {
- $this->findModel($id)->delete();
-
- return $this->redirect(['index']);
- }
-
- /**
- * Finds the Slider model based on its primary key value.
- * If the model is not found, a 404 HTTP exception will be thrown.
- * @param integer $id
- * @return Slider the loaded model
- * @throws NotFoundHttpException if the model cannot be found
- */
- protected function findModel($id)
- {
- if (($model = Slider::findOne($id)) !== null) {
- return $model;
- } else {
- throw new NotFoundHttpException('The requested page does not exist.');
+
+ /**
+ * Updates an existing Slider model.
+ * If update is successful, the browser will be redirected to the 'view' page.
+ *
+ * @param integer $id
+ *
+ * @return mixed
+ */
+ public function actionUpdate($id)
+ {
+ $model = $this->findModel($id);
+
+ if ($model->load(Yii::$app->request->post()) && $model->save()) {
+ return $this->redirect(
+ [
+ 'view',
+ 'id' => $model->id,
+ ]
+ );
+ } else {
+ return $this->render(
+ 'update',
+ [
+ 'model' => $model,
+ ]
+ );
+ }
+ }
+
+ /**
+ * Deletes an existing Slider model.
+ * If deletion is successful, the browser will be redirected to the 'index' page.
+ *
+ * @param integer $id
+ *
+ * @return mixed
+ */
+ public function actionDelete($id)
+ {
+ $this->findModel($id)
+ ->delete();
+
+ return $this->redirect([ 'index' ]);
+ }
+
+ /**
+ * Finds the Slider model based on its primary key value.
+ * If the model is not found, a 404 HTTP exception will be thrown.
+ *
+ * @param integer $id
+ *
+ * @return Slider the loaded model
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ protected function findModel($id)
+ {
+ if (( $model = Slider::findOne($id) ) !== null) {
+ return $model;
+ } else {
+ throw new NotFoundHttpException('The requested page does not exist.');
+ }
}
}
-}
diff --git a/backend/controllers/SliderImageController.php b/backend/controllers/SliderImageController.php
index b82c0e4..d576dfe 100755
--- a/backend/controllers/SliderImageController.php
+++ b/backend/controllers/SliderImageController.php
@@ -58,11 +58,14 @@
$searchModel = new SliderImageSearch();
$dataProvider = $searchModel->search($slider_id, Yii::$app->request->queryParams);
- return $this->render('index', [
- 'slider_id' => $slider_id,
- 'searchModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- ]);
+ return $this->render(
+ 'index',
+ [
+ 'slider_id' => $slider_id,
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ ]
+ );
}
/**
@@ -75,10 +78,13 @@
*/
public function actionView($slider_id, $id)
{
- return $this->render('view', [
- 'slider_id' => $slider_id,
- 'model' => $this->findModel($slider_id, $id),
- ]);
+ return $this->render(
+ 'view',
+ [
+ 'slider_id' => $slider_id,
+ 'model' => $this->findModel($slider_id, $id),
+ ]
+ );
}
/**
@@ -93,24 +99,29 @@
{
$model = new SliderImage();
$model->generateLangs();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
$model->loadLangs(\Yii::$app->request);
$model->slider_id = $slider_id;
- if($model->save() && $model->transactionStatus) {
- return $this->redirect([
- 'view',
- 'slider_id' => $slider_id,
- 'id' => $model->slider_image_id,
- ]);
+ if ($model->save() && $model->transactionStatus) {
+ return $this->redirect(
+ [
+ 'view',
+ 'slider_id' => $slider_id,
+ 'id' => $model->id,
+ ]
+ );
}
}
$slider = Slider::findOne($slider_id);
- return $this->render('create', [
- 'slider_id' => $slider_id,
- 'model' => $model,
- 'modelLangs' => $model->modelLangs,
- 'slider' => $slider,
- ]);
+ return $this->render(
+ 'create',
+ [
+ 'slider_id' => $slider_id,
+ 'model' => $model,
+ 'modelLangs' => $model->modelLangs,
+ 'slider' => $slider,
+ ]
+ );
}
/**
@@ -126,23 +137,28 @@
{
$model = $this->findModel($slider_id, $id);
$model->generateLangs();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
$model->loadLangs(\Yii::$app->request);
- if($model->save() && $model->transactionStatus) {
- return $this->redirect([
- 'view',
- 'slider_id' => $slider_id,
- 'id' => $model->slider_image_id,
- ]);
+ if ($model->save() && $model->transactionStatus) {
+ return $this->redirect(
+ [
+ 'view',
+ 'slider_id' => $slider_id,
+ 'id' => $model->id,
+ ]
+ );
}
}
$slider = Slider::findOne($slider_id);
- return $this->render('update', [
- 'model' => $model,
- 'modelLangs' => $model->modelLangs,
- 'slider_id' => $slider_id,
- 'slider' => $slider,
- ]);
+ return $this->render(
+ 'update',
+ [
+ 'model' => $model,
+ 'modelLangs' => $model->modelLangs,
+ 'slider_id' => $slider_id,
+ 'slider' => $slider,
+ ]
+ );
}
/**
@@ -159,10 +175,12 @@
$this->findModel($slider_id, $id)
->delete();
- return $this->redirect([
- 'index',
- 'slider_id' => $slider_id,
- ]);
+ return $this->redirect(
+ [
+ 'index',
+ 'slider_id' => $slider_id,
+ ]
+ );
}
/**
@@ -180,12 +198,14 @@
/**
* @var SliderImage $model
*/
- if(( $model = SliderImage::find()
- ->where([
- 'slider_image_id' => $id,
- 'slider_id' => $slider_id,
- ])
- ->one() ) !== NULL
+ if (( $model = SliderImage::find()
+ ->where(
+ [
+ 'id' => $id,
+ 'slider_id' => $slider_id,
+ ]
+ )
+ ->one() ) !== null
) {
return $model;
} else {
diff --git a/backend/models/OrderProducts.php b/backend/models/OrderProducts.php
index 7b536f3..cbfd16f 100755
--- a/backend/models/OrderProducts.php
+++ b/backend/models/OrderProducts.php
@@ -41,6 +41,6 @@
public function getMod()
{
- return $this->hasOne(ProductVariant::className(), [ 'product_variant_id' => 'product_variant_id' ]);
+ return $this->hasOne(ProductVariant::className(), [ 'id' => 'product_variant_id' ]);
}
}
\ No newline at end of file
diff --git a/backend/views/seo-category/index.php b/backend/views/seo-category/index.php
index ded2cf4..c98235b 100755
--- a/backend/views/seo-category/index.php
+++ b/backend/views/seo-category/index.php
@@ -19,32 +19,40 @@
= Html::a(Yii::t('app', 'Create Seo Category'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
- = GridView::widget([
- 'dataProvider' => $dataProvider,
- 'filterModel' => $searchModel,
- 'columns' => [
- [ 'class' => 'yii\grid\SerialColumn' ],
- 'seo_category_id',
- 'controller',
- [
- 'attribute' => 'title',
- 'value' => 'lang.title',
- ],
- 'status',
- [
- 'class' => 'yii\grid\ActionColumn',
- 'template' => '{update} {image} {delete}',
- 'buttons' => [
- 'image' => function($url, $model) {
- return Html::a('', Url::toRoute([
- 'seo-dynamic/index',
- 'seo_category_id' => $model->seo_category_id,
- ]), [
- 'title' => \Yii::t('app', 'слайды'),
- ]);
- },
+ = GridView::widget(
+ [
+ 'dataProvider' => $dataProvider,
+ 'filterModel' => $searchModel,
+ 'columns' => [
+ [ 'class' => 'yii\grid\SerialColumn' ],
+ 'id',
+ 'controller',
+ [
+ 'attribute' => 'title',
+ 'value' => 'lang.title',
+ ],
+ 'status',
+ [
+ 'class' => 'yii\grid\ActionColumn',
+ 'template' => '{update} {image} {delete}',
+ 'buttons' => [
+ 'image' => function ($url, $model) {
+ return Html::a(
+ '',
+ Url::toRoute(
+ [
+ 'seo-dynamic/index',
+ 'seo_category_id' => $model->id,
+ ]
+ ),
+ [
+ 'title' => \Yii::t('app', 'слайды'),
+ ]
+ );
+ },
+ ],
],
],
- ],
- ]); ?>
+ ]
+ ); ?>
diff --git a/backend/views/seo-category/update.php b/backend/views/seo-category/update.php
index f5bbbab..f061a68 100755
--- a/backend/views/seo-category/update.php
+++ b/backend/views/seo-category/update.php
@@ -22,7 +22,7 @@
'label' => $model->lang->title,
'url' => [
'view',
- 'id' => $model->seo_category_id,
+ 'id' => $model->id,
],
];
$this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update');
diff --git a/backend/views/seo-dynamic/create.php b/backend/views/seo-dynamic/create.php
index de1ba8b..ea7b633 100755
--- a/backend/views/seo-dynamic/create.php
+++ b/backend/views/seo-dynamic/create.php
@@ -23,7 +23,7 @@
'label' => $seo_category->lang->title,
'url' => [
'index',
- 'seo_category_id' => $seo_category->seo_category_id,
+ 'seo_category_id' => $seo_category->id,
],
];
$this->params[ 'breadcrumbs' ][] = $this->title;
@@ -32,9 +32,12 @@
= Html::encode($this->title) ?>
- = $this->render('_form', [
- 'model' => $model,
- 'modelLangs' => $modelLangs,
- ]) ?>
+ = $this->render(
+ '_form',
+ [
+ 'model' => $model,
+ 'modelLangs' => $modelLangs,
+ ]
+ ) ?>
diff --git a/backend/views/seo-dynamic/index.php b/backend/views/seo-dynamic/index.php
index eb7d1d6..051eb0a 100755
--- a/backend/views/seo-dynamic/index.php
+++ b/backend/views/seo-dynamic/index.php
@@ -11,9 +11,13 @@
* @var yii\data\ActiveDataProvider $dataProvider
* @var SeoCategory $seo_category
*/
- $this->title = Yii::t('app', 'Seo Dynamics for {seo_category}', [
- 'seo_category' => $seo_category->lang->title,
- ]);
+ $this->title = Yii::t(
+ 'app',
+ 'Seo Dynamics for {seo_category}',
+ [
+ 'seo_category' => $seo_category->lang->title,
+ ]
+ );
$this->params[ 'breadcrumbs' ][] = [
'label' => \Yii::t('app', 'Seo Categories'),
'url' => [ '/seo-category/index' ],
@@ -25,61 +29,83 @@
= Html::encode($this->title) ?>
- = Html::a(Yii::t('app', 'Create Seo Dynamic'), Url::toRoute([
- 'create',
- 'seo_category_id' => $seo_category->seo_category_id,
- ]), [ 'class' => 'btn btn-success' ]) ?>
+ = Html::a(
+ Yii::t('app', 'Create Seo Dynamic'),
+ Url::toRoute(
+ [
+ 'create',
+ 'seo_category_id' => $seo_category->id,
+ ]
+ ),
+ [ 'class' => 'btn btn-success' ]
+ ) ?>
- = GridView::widget([
- 'dataProvider' => $dataProvider,
- 'filterModel' => $searchModel,
- 'columns' => [
- [ 'class' => 'yii\grid\SerialColumn' ],
- 'seo_dynamic_id',
- [
- 'attribute' => 'title',
- 'value' => 'lang.title',
- ],
- 'action',
- 'fields',
- 'param',
- 'status',
- [
- 'class' => 'yii\grid\ActionColumn',
- 'buttons' => [
- 'view' => function($url, $model) {
- return Html::a('', [
- 'view',
- 'seo_category_id' => $model->seo_category_id,
- 'id' => $model->seo_dynamic_id,
- ], [
- 'title' => \Yii::t('app', 'Просмотр'),
- ]);
- },
- 'update' => function($url, $model) {
- return Html::a('', [
- 'update',
- 'seo_category_id' => $model->seo_category_id,
- 'id' => $model->seo_dynamic_id,
- ], [
- 'title' => \Yii::t('app', 'Редактировать'),
- ]);
- },
- 'delete' => function($url, $model) {
-
- return Html::a('', Url::toRoute([
- 'delete',
- 'seo_category_id' => $model->seo_category_id,
- 'id' => $model->seo_dynamic_id,
- ]), [
- 'title' => Yii::t('yii', 'Delete'),
- 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'),
- 'data-method' => 'post',
- ]);
-
- },
+ = GridView::widget(
+ [
+ 'dataProvider' => $dataProvider,
+ 'filterModel' => $searchModel,
+ 'columns' => [
+ [ 'class' => 'yii\grid\SerialColumn' ],
+ 'id',
+ [
+ 'attribute' => 'title',
+ 'value' => 'lang.title',
+ ],
+ 'action',
+ 'fields',
+ 'param',
+ 'status',
+ [
+ 'class' => 'yii\grid\ActionColumn',
+ 'buttons' => [
+ 'view' => function ($url, $model) {
+ return Html::a(
+ '',
+ [
+ 'view',
+ 'seo_category_id' => $model->id,
+ 'id' => $model->id,
+ ],
+ [
+ 'title' => \Yii::t('app', 'Просмотр'),
+ ]
+ );
+ },
+ 'update' => function ($url, $model) {
+ return Html::a(
+ '',
+ [
+ 'update',
+ 'seo_category_id' => $model->seo_category_id,
+ 'id' => $model->id,
+ ],
+ [
+ 'title' => \Yii::t('app', 'Редактировать'),
+ ]
+ );
+ },
+ 'delete' => function ($url, $model) {
+
+ return Html::a(
+ '',
+ Url::toRoute(
+ [
+ 'delete',
+ 'seo_category_id' => $model->seo_category_id,
+ 'id' => $model->id,
+ ]
+ ),
+ [
+ 'title' => Yii::t('yii', 'Delete'),
+ 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'),
+ 'data-method' => 'post',
+ ]
+ );
+
+ },
+ ],
],
],
- ],
- ]); ?>
+ ]
+ ); ?>
diff --git a/backend/views/seo-dynamic/update.php b/backend/views/seo-dynamic/update.php
index de5e514..4339efc 100755
--- a/backend/views/seo-dynamic/update.php
+++ b/backend/views/seo-dynamic/update.php
@@ -13,9 +13,13 @@
* @var SeoCategory $seo_category
*/
- $this->title = Yii::t('app', 'Update {modelClass}: ', [
- 'modelClass' => 'Seo Dynamic',
- ]) . $model->lang->title;
+ $this->title = Yii::t(
+ 'app',
+ 'Update {modelClass}: ',
+ [
+ 'modelClass' => 'Seo Dynamic',
+ ]
+ ) . $model->lang->title;
$this->params[ 'breadcrumbs' ][] = [
'label' => Yii::t('app', 'Seo Categories'),
'url' => [ '/seo-category/index' ],
@@ -24,15 +28,15 @@
'label' => $seo_category->lang->title,
'url' => [
'index',
- 'seo_category_id' => $seo_category->seo_category_id,
+ 'seo_category_id' => $seo_category->id,
],
];
$this->params[ 'breadcrumbs' ][] = [
'label' => $model->lang->title,
'url' => [
'view',
- 'seo_category_id' => $seo_category->seo_category_id,
- 'id' => $model->seo_dynamic_id,
+ 'seo_category_id' => $seo_category->id,
+ 'id' => $model->id,
],
];
$this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update');
@@ -41,9 +45,12 @@
= Html::encode($this->title) ?>
- = $this->render('_form', [
- 'model' => $model,
- 'modelLangs' => $modelLangs,
- ]) ?>
+ = $this->render(
+ '_form',
+ [
+ 'model' => $model,
+ 'modelLangs' => $modelLangs,
+ ]
+ ) ?>
diff --git a/backend/views/seo-dynamic/view.php b/backend/views/seo-dynamic/view.php
index bcc2798..7801532 100755
--- a/backend/views/seo-dynamic/view.php
+++ b/backend/views/seo-dynamic/view.php
@@ -18,7 +18,7 @@
'label' => $seo_category->lang->title,
'url' => [
'index',
- 'seo_category_id' => $seo_category->seo_category_id,
+ 'seo_category_id' => $seo_category->id,
],
];
$this->params[ 'breadcrumbs' ][] = $this->title;
@@ -28,48 +28,61 @@
= Html::encode($this->title) ?>
- = Html::a(Yii::t('app', 'Update'), [
- 'update',
- 'id' => $model->seo_dynamic_id,
- 'seo_category_id' => $seo_category->seo_category_id,
- ], [ 'class' => 'btn btn-primary' ]) ?>
- = Html::a(Yii::t('app', 'Delete'), [
- 'delete',
- 'id' => $model->seo_dynamic_id,
- 'seo_category_id' => $seo_category->seo_category_id,
- ], [
- 'class' => 'btn btn-danger',
- 'data' => [
- 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
- 'method' => 'post',
+ = Html::a(
+ Yii::t('app', 'Update'),
+ [
+ 'update',
+ 'id' => $model->id,
+ 'seo_category_id' => $seo_category->id,
+ ],
+ [ 'class' => 'btn btn-primary' ]
+ ) ?>
+ = Html::a(
+ Yii::t('app', 'Delete'),
+ [
+ 'delete',
+ 'id' => $model->id,
+ 'seo_category_id' => $seo_category->id,
],
- ]) ?>
+ [
+ 'class' => 'btn btn-danger',
+ 'data' => [
+ 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
+ 'method' => 'post',
+ ],
+ ]
+ ) ?>
- = DetailView::widget([
- 'model' => $model,
- 'attributes' => [
- 'seo_dynamic_id',
- [
- 'label' => \Yii::t('app', 'Seo Category'),
- 'value' => Html::a($seo_category->lang->title, [
- 'index',
- 'seo_category_id' => $seo_category->seo_category_id,
- ]),
- 'format' => 'html',
+ = DetailView::widget(
+ [
+ 'model' => $model,
+ 'attributes' => [
+ 'id',
+ [
+ 'label' => \Yii::t('app', 'Seo Category'),
+ 'value' => Html::a(
+ $seo_category->lang->title,
+ [
+ 'index',
+ 'seo_category_id' => $seo_category->id,
+ ]
+ ),
+ 'format' => 'html',
+ ],
+ 'lang.title',
+ 'action',
+ 'fields',
+ 'param',
+ 'status',
+ 'lang.meta_title',
+ 'lang.h1',
+ 'lang.key',
+ 'lang.meta',
+ 'lang.meta_description',
+ 'lang.seo_text',
],
- 'lang.title',
- 'action',
- 'fields',
- 'param',
- 'status',
- 'lang.meta_title',
- 'lang.h1',
- 'lang.key',
- 'lang.meta',
- 'lang.meta_description',
- 'lang.seo_text',
- ],
- ]) ?>
+ ]
+ ) ?>
diff --git a/backend/views/seo/index.php b/backend/views/seo/index.php
index 4269597..d88cac6 100755
--- a/backend/views/seo/index.php
+++ b/backend/views/seo/index.php
@@ -18,34 +18,36 @@
= Html::a(Yii::t('app', 'Create Seo'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
- = GridView::widget([
- 'dataProvider' => $dataProvider,
- 'filterModel' => $searchModel,
- 'columns' => [
- [ 'class' => 'yii\grid\SerialColumn' ],
- 'seo_id',
- 'url',
- [
- 'attribute' => 'title',
- 'value' => 'lang.title',
+ = GridView::widget(
+ [
+ 'dataProvider' => $dataProvider,
+ 'filterModel' => $searchModel,
+ 'columns' => [
+ [ 'class' => 'yii\grid\SerialColumn' ],
+ 'id',
+ 'url',
+ [
+ 'attribute' => 'title',
+ 'value' => 'lang.title',
+ ],
+ [
+ 'attribute' => 'meta_description',
+ 'value' => 'lang.meta_description',
+ ],
+ [
+ 'attribute' => 'h1',
+ 'value' => 'lang.h1',
+ ],
+ [
+ 'attribute' => 'meta',
+ 'value' => 'lang.meta',
+ ],
+ [
+ 'attribute' => 'seo_text',
+ 'value' => 'lang.seo_text',
+ ],
+ [ 'class' => 'yii\grid\ActionColumn' ],
],
- [
- 'attribute' => 'meta_description',
- 'value' => 'lang.meta_description',
- ],
- [
- 'attribute' => 'h1',
- 'value' => 'lang.h1',
- ],
- [
- 'attribute' => 'meta',
- 'value' => 'lang.meta',
- ],
- [
- 'attribute' => 'seo_text',
- 'value' => 'lang.seo_text',
- ],
- [ 'class' => 'yii\grid\ActionColumn' ],
- ],
- ]); ?>
+ ]
+ ); ?>
diff --git a/backend/views/seo/update.php b/backend/views/seo/update.php
index 965d036..62d22d4 100755
--- a/backend/views/seo/update.php
+++ b/backend/views/seo/update.php
@@ -11,9 +11,13 @@
* @var SeoLang[] $modelLangs
*/
- $this->title = Yii::t('app', 'Update {modelClass}: ', [
- 'modelClass' => 'Seo',
- ]) . $model->url;
+ $this->title = Yii::t(
+ 'app',
+ 'Update {modelClass}: ',
+ [
+ 'modelClass' => 'Seo',
+ ]
+ ) . $model->url;
$this->params[ 'breadcrumbs' ][] = [
'label' => Yii::t('app', 'Seos'),
'url' => [ 'index' ],
@@ -22,7 +26,7 @@
'label' => $model->url,
'url' => [
'view',
- 'id' => $model->seo_id,
+ 'id' => $model->id,
],
];
$this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update');
@@ -31,9 +35,12 @@
= Html::encode($this->title) ?>
- = $this->render('_form', [
- 'model' => $model,
- 'modelLangs' => $modelLangs,
- ]) ?>
+ = $this->render(
+ '_form',
+ [
+ 'model' => $model,
+ 'modelLangs' => $modelLangs,
+ ]
+ ) ?>
diff --git a/backend/views/seo/view.php b/backend/views/seo/view.php
index 5ce7444..b919c3d 100755
--- a/backend/views/seo/view.php
+++ b/backend/views/seo/view.php
@@ -19,33 +19,43 @@
= Html::encode($this->title) ?>
- = Html::a(Yii::t('app', 'Update'), [
- 'update',
- 'id' => $model->seo_id,
- ], [ 'class' => 'btn btn-primary' ]) ?>
- = Html::a(Yii::t('app', 'Delete'), [
- 'delete',
- 'id' => $model->seo_id,
- ], [
- 'class' => 'btn btn-danger',
- 'data' => [
- 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
- 'method' => 'post',
+ = Html::a(
+ Yii::t('app', 'Update'),
+ [
+ 'update',
+ 'id' => $model->id,
],
- ]) ?>
+ [ 'class' => 'btn btn-primary' ]
+ ) ?>
+ = Html::a(
+ Yii::t('app', 'Delete'),
+ [
+ 'delete',
+ 'id' => $model->id,
+ ],
+ [
+ 'class' => 'btn btn-danger',
+ 'data' => [
+ 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
+ 'method' => 'post',
+ ],
+ ]
+ ) ?>
- = DetailView::widget([
- 'model' => $model,
- 'attributes' => [
- 'seo_id',
- 'url',
- 'lang.title',
- 'lang.meta_description',
- 'lang.h1',
- 'lang.meta',
- 'lang.seo_text',
- ],
- ]) ?>
+ = DetailView::widget(
+ [
+ 'model' => $model,
+ 'attributes' => [
+ 'id',
+ 'url',
+ 'lang.title',
+ 'lang.meta_description',
+ 'lang.h1',
+ 'lang.meta',
+ 'lang.seo_text',
+ ],
+ ]
+ ) ?>
diff --git a/backend/views/service/index.php b/backend/views/service/index.php
index 6d37430..61132b6 100755
--- a/backend/views/service/index.php
+++ b/backend/views/service/index.php
@@ -18,17 +18,19 @@
= Html::a(Yii::t('app', 'Create Service'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
- = GridView::widget([
- 'dataProvider' => $dataProvider,
- 'filterModel' => $searchModel,
- 'columns' => [
- [ 'class' => 'yii\grid\SerialColumn' ],
-
- 'service_id',
- 'imageUrl:image',
- 'created_at:date',
-
- [ 'class' => 'yii\grid\ActionColumn' ],
- ],
- ]); ?>
+ = GridView::widget(
+ [
+ 'dataProvider' => $dataProvider,
+ 'filterModel' => $searchModel,
+ 'columns' => [
+ [ 'class' => 'yii\grid\SerialColumn' ],
+
+ 'id',
+ 'imageUrl:image',
+ 'created_at:date',
+
+ [ 'class' => 'yii\grid\ActionColumn' ],
+ ],
+ ]
+ ); ?>
diff --git a/backend/views/service/update.php b/backend/views/service/update.php
index 7dea7db..f5763bc 100755
--- a/backend/views/service/update.php
+++ b/backend/views/service/update.php
@@ -11,18 +11,22 @@
* @var ServiceLang[] $modelLangs
*/
- $this->title = Yii::t('app', 'Update {modelClass}: ', [
- 'modelClass' => 'Service',
- ]) . $model->service_id;
+ $this->title = Yii::t(
+ 'app',
+ 'Update {modelClass}: ',
+ [
+ 'modelClass' => 'Service',
+ ]
+ ) . $model->id;
$this->params[ 'breadcrumbs' ][] = [
'label' => Yii::t('app', 'Services'),
'url' => [ 'index' ],
];
$this->params[ 'breadcrumbs' ][] = [
- 'label' => $model->service_id,
+ 'label' => $model->id,
'url' => [
'view',
- 'id' => $model->service_id,
+ 'id' => $model->id,
],
];
$this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update');
@@ -31,9 +35,12 @@
= Html::encode($this->title) ?>
- = $this->render('_form', [
- 'model' => $model,
- 'modelLangs' => $modelLangs,
- ]) ?>
+ = $this->render(
+ '_form',
+ [
+ 'model' => $model,
+ 'modelLangs' => $modelLangs,
+ ]
+ ) ?>
diff --git a/backend/views/service/view.php b/backend/views/service/view.php
index 9679fdc..ea74d77 100755
--- a/backend/views/service/view.php
+++ b/backend/views/service/view.php
@@ -6,7 +6,7 @@
/* @var $this yii\web\View */
/* @var $model common\models\Service */
- $this->title = $model->service_id;
+ $this->title = $model->id;
$this->params[ 'breadcrumbs' ][] = [
'label' => Yii::t('app', 'Services'),
'url' => [ 'index' ],
@@ -18,29 +18,39 @@
= Html::encode($this->title) ?>
- = Html::a(Yii::t('app', 'Update'), [
- 'update',
- 'id' => $model->service_id,
- ], [ 'class' => 'btn btn-primary' ]) ?>
- = Html::a(Yii::t('app', 'Delete'), [
- 'delete',
- 'id' => $model->service_id,
- ], [
- 'class' => 'btn btn-danger',
- 'data' => [
- 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
- 'method' => 'post',
+ = Html::a(
+ Yii::t('app', 'Update'),
+ [
+ 'update',
+ 'id' => $model->id,
],
- ]) ?>
+ [ 'class' => 'btn btn-primary' ]
+ ) ?>
+ = Html::a(
+ Yii::t('app', 'Delete'),
+ [
+ 'delete',
+ 'id' => $model->id,
+ ],
+ [
+ 'class' => 'btn btn-danger',
+ 'data' => [
+ 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
+ 'method' => 'post',
+ ],
+ ]
+ ) ?>
- = DetailView::widget([
- 'model' => $model,
- 'attributes' => [
- 'service_id',
- 'imageUrl:image',
- 'created_at:date',
- ],
- ]) ?>
+ = DetailView::widget(
+ [
+ 'model' => $model,
+ 'attributes' => [
+ 'id',
+ 'imageUrl:image',
+ 'created_at:date',
+ ],
+ ]
+ ) ?>
diff --git a/backend/views/slider-image/index.php b/backend/views/slider-image/index.php
index cbe1ee0..41b5c2f 100755
--- a/backend/views/slider-image/index.php
+++ b/backend/views/slider-image/index.php
@@ -23,66 +23,92 @@
= Html::encode($this->title) ?>
- = Html::a(Yii::t('app', 'Create Slider Image'), Url::toRoute([
- 'create',
- 'slider_id' => $slider_id,
- ]), [ 'class' => 'btn btn-success' ]) ?>
+ = Html::a(
+ Yii::t('app', 'Create Slider Image'),
+ Url::toRoute(
+ [
+ 'create',
+ 'slider_id' => $slider_id,
+ ]
+ ),
+ [ 'class' => 'btn btn-success' ]
+ ) ?>
- = GridView::widget([
- 'dataProvider' => $dataProvider,
- 'filterModel' => $searchModel,
- 'columns' => [
- 'slider_image_id',
- 'imageUrl:image',
- 'url',
- [
- 'attribute' => 'status',
- 'value' => function($model) {
- /**
- * @var SliderImage $model
- */
- return ( !$model->status ) ? \Yii::t('app', 'Скрыто') : \Yii::t('app', 'Показать');
- },
- 'filter' => [
- 0 => \Yii::t('app', 'Скрыто'),
- 1 => \Yii::t('app', 'Показать'),
- ],
- ],
- [
- 'class' => 'yii\grid\ActionColumn',
- 'buttons' => [
- 'view' => function($url, $model) {
- return Html::a('', Url::toRoute([
- 'view',
- 'slider_id' => $model->slider_id,
- 'id' => $model->slider_image_id,
- ]), [
- 'title' => \Yii::t('app', 'Просмотр'),
- ]);
- },
- 'update' => function($url, $model) {
- return Html::a('', Url::toRoute([
- 'update',
- 'slider_id' => $model->slider_id,
- 'id' => $model->slider_image_id,
- ]), [
- 'title' => \Yii::t('app', 'Редактировать'),
- ]);
- },
- 'delete' => function($url, $model) {
- return Html::a('', Url::toRoute([
- 'delete',
- 'slider_id' => $model->slider_id,
- 'id' => $model->slider_image_id,
- ]), [
- 'title' => Yii::t('yii', 'Delete'),
- 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'),
- 'data-method' => 'post',
- ]);
-
+ = GridView::widget(
+ [
+ 'dataProvider' => $dataProvider,
+ 'filterModel' => $searchModel,
+ 'columns' => [
+ 'id',
+ 'imageUrl:image',
+ 'url',
+ [
+ 'attribute' => 'status',
+ 'value' => function ($model) {
+ /**
+ * @var SliderImage $model
+ */
+ return ( !$model->status ) ? \Yii::t('app', 'Скрыто') : \Yii::t('app', 'Показать');
},
+ 'filter' => [
+ 0 => \Yii::t('app', 'Скрыто'),
+ 1 => \Yii::t('app', 'Показать'),
+ ],
+ ],
+ [
+ 'class' => 'yii\grid\ActionColumn',
+ 'buttons' => [
+ 'view' => function ($url, $model) {
+ return Html::a(
+ '',
+ Url::toRoute(
+ [
+ 'view',
+ 'slider_id' => $model->slider_id,
+ 'id' => $model->id,
+ ]
+ ),
+ [
+ 'title' => \Yii::t('app', 'Просмотр'),
+ ]
+ );
+ },
+ 'update' => function ($url, $model) {
+ return Html::a(
+ '',
+ Url::toRoute(
+ [
+ 'update',
+ 'slider_id' => $model->slider_id,
+ 'id' => $model->id,
+ ]
+ ),
+ [
+ 'title' => \Yii::t('app', 'Редактировать'),
+ ]
+ );
+ },
+ 'delete' => function ($url, $model) {
+ return Html::a(
+ '',
+ Url::toRoute(
+ [
+ 'delete',
+ 'slider_id' => $model->slider_id,
+ 'id' => $model->id,
+ ]
+ ),
+ [
+ 'title' => Yii::t('yii', 'Delete'),
+ 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'),
+ 'data-method' => 'post',
+ ]
+ );
+
+ },
+ ],
],
],
- ],
- ]); ?>
+ ]
+ ); ?>
diff --git a/backend/views/slider-image/update.php b/backend/views/slider-image/update.php
index a17b813..96a3fe2 100755
--- a/backend/views/slider-image/update.php
+++ b/backend/views/slider-image/update.php
@@ -15,29 +15,39 @@
* @var int $slider_id
*/
- $this->title = Yii::t('app', 'Update {modelClass}: ', [
- 'modelClass' => 'Slider Image',
- ]) . $model->slider_image_id;
+ $this->title = Yii::t(
+ 'app',
+ 'Update {modelClass}: ',
+ [
+ 'modelClass' => 'Slider Image',
+ ]
+ ) . $model->id;
$this->params[ 'breadcrumbs' ][] = [
'label' => Yii::t('app', 'Sliders'),
- 'url' => Url::toRoute([
- 'slider/index',
- ]),
+ 'url' => Url::toRoute(
+ [
+ 'slider/index',
+ ]
+ ),
];
$this->params[ 'breadcrumbs' ][] = [
'label' => Yii::t('app', 'Slider Images'),
- 'url' => Url::toRoute([
- 'index',
- 'slider_id' => $slider_id,
- ]),
+ 'url' => Url::toRoute(
+ [
+ 'index',
+ 'slider_id' => $slider_id,
+ ]
+ ),
];
$this->params[ 'breadcrumbs' ][] = [
- 'label' => \Yii::t('app', 'Slide').': '.$model->slider_image_id,
- 'url' => Url::toRoute([
- 'view',
- 'slider_id' => $slider_id,
- 'id' => $model->slider_image_id,
- ]),
+ 'label' => \Yii::t('app', 'Slide') . ': ' . $model->id,
+ 'url' => Url::toRoute(
+ [
+ 'view',
+ 'slider_id' => $slider_id,
+ 'id' => $model->id,
+ ]
+ ),
];
$this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update');
?>
@@ -45,10 +55,13 @@
= Html::encode($this->title) ?>
- = $this->render('_form', [
- 'model' => $model,
- 'modelLangs' => $modelLangs,
- 'slider' => $slider,
- ]) ?>
+ = $this->render(
+ '_form',
+ [
+ 'model' => $model,
+ 'modelLangs' => $modelLangs,
+ 'slider' => $slider,
+ ]
+ ) ?>
diff --git a/backend/views/slider-image/view.php b/backend/views/slider-image/view.php
index 2d55aa7..7aff7be 100755
--- a/backend/views/slider-image/view.php
+++ b/backend/views/slider-image/view.php
@@ -9,19 +9,23 @@
* @var common\models\SliderImage $model
* @var int $slider_id
*/
- $this->title = \Yii::t('app', 'Slide') . ': ' . $model->slider_image_id;
+ $this->title = \Yii::t('app', 'Slide') . ': ' . $model->id;
$this->params[ 'breadcrumbs' ][] = [
'label' => Yii::t('app', 'Sliders'),
- 'url' => Url::toRoute([
- 'slider/index',
- ]),
+ 'url' => Url::toRoute(
+ [
+ 'slider/index',
+ ]
+ ),
];
$this->params[ 'breadcrumbs' ][] = [
'label' => Yii::t('app', 'Slider Images'),
- 'url' => Url::toRoute([
- 'index',
- 'slider_id' => $slider_id,
- ]),
+ 'url' => Url::toRoute(
+ [
+ 'index',
+ 'slider_id' => $slider_id,
+ ]
+ ),
];
$this->params[ 'breadcrumbs' ][] = $this->title;
?>
@@ -30,46 +34,59 @@
= Html::encode($this->title) ?>
- = Html::a(Yii::t('app', 'Update'), [
- 'update',
- 'slider_id' => $slider_id,
- 'id' => $model->slider_image_id,
- ], [ 'class' => 'btn btn-primary' ]) ?>
- = Html::a(Yii::t('app', 'Delete'), [
- 'delete',
- 'slider_id' => $slider_id,
- 'id' => $model->slider_image_id,
- ], [
- 'class' => 'btn btn-danger',
- 'data' => [
- 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
- 'method' => 'post',
+ = Html::a(
+ Yii::t('app', 'Update'),
+ [
+ 'update',
+ 'slider_id' => $slider_id,
+ 'id' => $model->id,
],
- ]) ?>
-
-
- = DetailView::widget([
- 'model' => $model,
- 'attributes' => [
- 'slider_image_id',
+ [ 'class' => 'btn btn-primary' ]
+ ) ?>
+ = Html::a(
+ Yii::t('app', 'Delete'),
[
- 'attribute' => 'slider_id',
- 'format' => 'html',
- 'value' => Html::a($model->slider->title, [
- 'slider/update',
- 'id' => $model->slider_id,
- ]),
+ 'delete',
+ 'slider_id' => $slider_id,
+ 'id' => $model->id,
],
- 'lang.title',
- 'lang.alt',
- 'imageUrl:image',
- 'url:url',
[
- 'attribute' => 'status',
- 'value' => $model->status?\Yii::t('app', 'Показать'):\Yii::t('app', 'Скрыть'),
+ 'class' => 'btn btn-danger',
+ 'data' => [
+ 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
+ 'method' => 'post',
+ ],
+ ]
+ ) ?>
+
+
+ = DetailView::widget(
+ [
+ 'model' => $model,
+ 'attributes' => [
+ 'id',
+ [
+ 'attribute' => 'slider_id',
+ 'format' => 'html',
+ 'value' => Html::a(
+ $model->slider->title,
+ [
+ 'slider/update',
+ 'id' => $model->slider_id,
+ ]
+ ),
+ ],
+ 'lang.title',
+ 'lang.alt',
+ 'imageUrl:image',
+ 'url:url',
+ [
+ 'attribute' => 'status',
+ 'value' => $model->status ? \Yii::t('app', 'Показать') : \Yii::t('app', 'Скрыть'),
+ ],
+ 'sort',
],
- 'sort',
- ],
- ]) ?>
+ ]
+ ) ?>
diff --git a/backend/views/slider/index.php b/backend/views/slider/index.php
index e80f89e..c5596d4 100755
--- a/backend/views/slider/index.php
+++ b/backend/views/slider/index.php
@@ -20,48 +20,56 @@
= Html::a(Yii::t('app', 'Create Slider'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
- = GridView::widget([
- 'dataProvider' => $dataProvider,
- 'filterModel' => $searchModel,
- 'columns' => [
- 'slider_id',
- 'title',
- [
- 'attribute' => 'status',
- 'value' => function($model) {
- /**
- * @var Slider $model
- */
- return ( !$model->status ) ? \Yii::t('app', 'Скрыто') : \Yii::t('app', 'Показать');
- },
- 'filter' => [
- 0 => \Yii::t('app', 'Скрыто'),
- 1 => \Yii::t('app', 'Показать'),
+ = GridView::widget(
+ [
+ 'dataProvider' => $dataProvider,
+ 'filterModel' => $searchModel,
+ 'columns' => [
+ 'id',
+ 'title',
+ [
+ 'attribute' => 'status',
+ 'value' => function ($model) {
+ /**
+ * @var Slider $model
+ */
+ return ( !$model->status ) ? \Yii::t('app', 'Скрыто') : \Yii::t('app', 'Показать');
+ },
+ 'filter' => [
+ 0 => \Yii::t('app', 'Скрыто'),
+ 1 => \Yii::t('app', 'Показать'),
+ ],
],
- ],
- [
- 'label' => \Yii::t('app', 'Slide count'),
- 'content' => function($model) {
- /**
- * @var Slider $model
- */
+ [
+ 'label' => \Yii::t('app', 'Slide count'),
+ 'content' => function ($model) {
+ /**
+ * @var Slider $model
+ */
return count($model->sliderImage);
- },
- ],
- [
- 'class' => 'yii\grid\ActionColumn',
- 'template' => '{update} {image} {delete}',
- 'buttons' => [
- 'image' => function($url, $model) {
- return Html::a('', Url::toRoute([
- 'slider-image/index',
- 'slider_id' => $model->slider_id,
- ]), [
- 'title' => \Yii::t('app', "слайды"),
- ]);
},
],
+ [
+ 'class' => 'yii\grid\ActionColumn',
+ 'template' => '{update} {image} {delete}',
+ 'buttons' => [
+ 'image' => function ($url, $model) {
+ return Html::a(
+ '',
+ Url::toRoute(
+ [
+ 'slider-image/index',
+ 'slider_id' => $model->id,
+ ]
+ ),
+ [
+ 'title' => \Yii::t('app', "слайды"),
+ ]
+ );
+ },
+ ],
+ ],
],
- ],
- ]); ?>
+ ]
+ ); ?>
diff --git a/common/models/Basket.php b/common/models/Basket.php
index 9ffc7bd..de348be 100755
--- a/common/models/Basket.php
+++ b/common/models/Basket.php
@@ -93,7 +93,7 @@
* @var ProductVariant $model
*/
$model = ProductVariant::find()
- ->where([ 'product_variant.product_variant_id' => $product_variant_id ])
+ ->where([ 'product_variant.id' => $product_variant_id ])
->joinWith('lang', true, 'INNER JOIN')
->one();
if(empty( $model )) {
@@ -106,7 +106,7 @@
public function findModels(array $product_variant_ids)
{
return ProductVariant::find()
- ->where([ 'product_variant.product_variant_id' => $product_variant_ids ])
+ ->where([ 'product_variant.id' => $product_variant_ids ])
->joinWith('lang', true, 'INNER JOIN')
->with([
'product',
diff --git a/common/models/Order.php b/common/models/Order.php
index d7668f7..7e13337 100755
--- a/common/models/Order.php
+++ b/common/models/Order.php
@@ -217,7 +217,7 @@
'product.alias',
]
)
- ->where([ 'product_variant.product_variant_id' => $product[ 'id' ] ])
+ ->where([ 'product_variant.id' => $product[ 'id' ] ])
->leftJoin('product', 'product.id = product_variant.product_id')
->one();
$row->count = $product[ 'count' ];
@@ -249,7 +249,7 @@
* @var ProductVariant $mod
*/
$mod = ProductVariant::find()
- ->where([ 'product_variant_id' => $product_variant_id ])
+ ->where([ 'id' => $product_variant_id ])
->one();
return $mod->price;
diff --git a/common/models/OrderProduct.php b/common/models/OrderProduct.php
index a3e09de..6f61e86 100755
--- a/common/models/OrderProduct.php
+++ b/common/models/OrderProduct.php
@@ -51,6 +51,6 @@
public function getProductVariant()
{
- return $this->hasOne(ProductVariant::className(), [ 'product_variant_id' => 'product_variant_id' ]);
+ return $this->hasOne(ProductVariant::className(), [ 'id' => 'product_variant_id' ]);
}
}
\ No newline at end of file
diff --git a/common/models/Seo.php b/common/models/Seo.php
index 4d7d25f..3a6bf52 100755
--- a/common/models/Seo.php
+++ b/common/models/Seo.php
@@ -10,7 +10,8 @@
/**
* This is the model class for table "seo".
- * @property integer $seo_id
+ *
+ * @property integer $id
* @property string $url
* * From language behavior *
* @property SeoLang $lang
@@ -77,8 +78,8 @@
public function attributeLabels()
{
return [
- 'seo_id' => Yii::t('app', 'seo_id'),
- 'url' => Yii::t('app', 'url'),
+ 'id' => Yii::t('app', 'seo_id'),
+ 'url' => Yii::t('app', 'url'),
];
}
}
diff --git a/common/models/SeoCategory.php b/common/models/SeoCategory.php
index 7467905..bbdd697 100755
--- a/common/models/SeoCategory.php
+++ b/common/models/SeoCategory.php
@@ -10,7 +10,8 @@
/**
* This is the model class for table "seo_category".
- * @property integer $seo_category_id
+ *
+ * @property integer $id
* @property string $controller
* @property integer $status
* * From language behavior *
@@ -79,9 +80,9 @@
public function attributeLabels()
{
return [
- 'seo_category_id' => Yii::t('app', 'seo_category_id'),
- 'controller' => Yii::t('app', 'controller'),
- 'status' => Yii::t('app', 'status'),
+ 'id' => Yii::t('app', 'seo_category_id'),
+ 'controller' => Yii::t('app', 'controller'),
+ 'status' => Yii::t('app', 'status'),
];
}
@@ -90,6 +91,6 @@
*/
public function getSeoDynamics()
{
- return $this->hasMany(SeoDynamic::className(), [ 'seo_category_id' => 'seo_category_id' ]);
+ return $this->hasMany(SeoDynamic::className(), [ 'seo_category_id' => 'id' ]);
}
}
diff --git a/common/models/SeoCategoryLang.php b/common/models/SeoCategoryLang.php
index d78bcbc..e318718 100755
--- a/common/models/SeoCategoryLang.php
+++ b/common/models/SeoCategoryLang.php
@@ -8,6 +8,7 @@
/**
* This is the model class for table "seo_category_lang".
+ *
* @property integer $seo_category_id
* @property integer $language_id
* @property string $title
@@ -68,7 +69,7 @@
'exist',
'skipOnError' => true,
'targetClass' => SeoCategory::className(),
- 'targetAttribute' => [ 'seo_category_id' => 'seo_category_id' ],
+ 'targetAttribute' => [ 'seo_category_id' => 'id' ],
],
];
}
@@ -81,7 +82,7 @@
return [
'seo_category_id' => Yii::t('app', 'seo_category_id'),
'language_id' => Yii::t('app', 'language_id'),
- 'title' => Yii::t('app', 'name'),
+ 'title' => Yii::t('app', 'name'),
];
}
@@ -98,6 +99,6 @@
*/
public function getSeoCategory()
{
- return $this->hasOne(SeoCategory::className(), [ 'seo_category_id' => 'seo_category_id' ]);
+ return $this->hasOne(SeoCategory::className(), [ 'id' => 'seo_category_id' ]);
}
}
diff --git a/common/models/SeoCategorySearch.php b/common/models/SeoCategorySearch.php
index 57665cd..e10e1a8 100755
--- a/common/models/SeoCategorySearch.php
+++ b/common/models/SeoCategorySearch.php
@@ -27,7 +27,7 @@
return [
[
[
- 'seo_category_id',
+ 'id',
'status',
],
'integer',
@@ -65,45 +65,53 @@
// add conditions that should always apply here
- $dataProvider = new ActiveDataProvider([
- 'query' => $query,
- 'sort' => [
- 'attributes' => [
- 'seo_category_id',
- 'controller',
- 'status',
- 'title' => [
- 'asc' => [ 'seo_category_lang.title' => SORT_ASC ],
- 'desc' => [ 'seo_category_lang.title' => SORT_DESC ],
+ $dataProvider = new ActiveDataProvider(
+ [
+ 'query' => $query,
+ 'sort' => [
+ 'attributes' => [
+ 'id',
+ 'controller',
+ 'status',
+ 'title' => [
+ 'asc' => [ 'seo_category_lang.title' => SORT_ASC ],
+ 'desc' => [ 'seo_category_lang.title' => SORT_DESC ],
+ ],
],
],
- ],
- ]);
+ ]
+ );
$this->load($params);
- if(!$this->validate()) {
+ 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;
}
// grid filtering conditions
- $query->andFilterWhere([
- 'seo_category_id' => $this->seo_category_id,
- 'status' => $this->status,
- ]);
+ $query->andFilterWhere(
+ [
+ 'id' => $this->id,
+ 'status' => $this->status,
+ ]
+ );
- $query->andFilterWhere([
- 'like',
- 'controller',
- $this->controller,
- ])
- ->andFilterWhere([
- 'ilike',
- 'seo_category_lang.title',
- $this->title,
- ]);
+ $query->andFilterWhere(
+ [
+ 'like',
+ 'controller',
+ $this->controller,
+ ]
+ )
+ ->andFilterWhere(
+ [
+ 'ilike',
+ 'seo_category_lang.title',
+ $this->title,
+ ]
+ );
return $dataProvider;
}
diff --git a/common/models/SeoDynamic.php b/common/models/SeoDynamic.php
index bb62365..456db25 100755
--- a/common/models/SeoDynamic.php
+++ b/common/models/SeoDynamic.php
@@ -10,7 +10,8 @@
/**
* This is the model class for table "seo_dynamic".
- * @property integer $seo_dynamic_id
+ *
+ * @property integer $id
* @property integer $seo_category_id
* @property string $action
* @property string $fields
@@ -91,7 +92,7 @@
'exist',
'skipOnError' => true,
'targetClass' => SeoCategory::className(),
- 'targetAttribute' => [ 'seo_category_id' => 'seo_category_id' ],
+ 'targetAttribute' => [ 'seo_category_id' => 'id' ],
],
];
}
@@ -102,7 +103,7 @@
public function attributeLabels()
{
return [
- 'seo_dynamic_id' => Yii::t('app', 'seo_dynamic_id'),
+ 'id' => Yii::t('app', 'seo_dynamic_id'),
'seo_category_id' => Yii::t('app', 'seo_category_id'),
'action' => Yii::t('app', 'action'),
'fields' => Yii::t('app', 'fields'),
@@ -116,6 +117,6 @@
*/
public function getSeoCategory()
{
- return $this->hasOne(SeoCategory::className(), [ 'seo_category_id' => 'seo_category_id' ]);
+ return $this->hasOne(SeoCategory::className(), [ 'id' => 'seo_category_id' ]);
}
}
diff --git a/common/models/SeoDynamicLang.php b/common/models/SeoDynamicLang.php
index 6678570..555c713 100755
--- a/common/models/SeoDynamicLang.php
+++ b/common/models/SeoDynamicLang.php
@@ -8,6 +8,7 @@
/**
* This is the model class for table "seo_dynamic_lang".
+ *
* @property integer $seo_dynamic_id
* @property integer $language_id
* @property string $title
@@ -87,7 +88,7 @@
'exist',
'skipOnError' => true,
'targetClass' => SeoDynamic::className(),
- 'targetAttribute' => [ 'seo_dynamic_id' => 'seo_dynamic_id' ],
+ 'targetAttribute' => [ 'seo_dynamic_id' => 'id' ],
],
];
}
@@ -98,15 +99,15 @@
public function attributeLabels()
{
return [
- 'seo_dynamic_id' => Yii::t('app', 'seo_dynamic_id'),
- 'language_id' => Yii::t('app', 'language_id'),
- 'title' => Yii::t('app', 'name'),
- 'meta_title' => Yii::t('app', 'title'),
- 'h1' => Yii::t('app', 'h1'),
- 'key' => Yii::t('app', 'key'),
- 'meta' => Yii::t('app', 'meta'),
- 'meta_description' => Yii::t('app', 'meta_description'),
- 'seo_text' => Yii::t('app', 'seo_text'),
+ 'seo_dynamic_id' => Yii::t('app', 'seo_dynamic_id'),
+ 'language_id' => Yii::t('app', 'language_id'),
+ 'title' => Yii::t('app', 'name'),
+ 'meta_title' => Yii::t('app', 'title'),
+ 'h1' => Yii::t('app', 'h1'),
+ 'key' => Yii::t('app', 'key'),
+ 'meta' => Yii::t('app', 'meta'),
+ 'meta_description' => Yii::t('app', 'meta_description'),
+ 'seo_text' => Yii::t('app', 'seo_text'),
];
}
@@ -123,6 +124,6 @@
*/
public function getSeoDynamic()
{
- return $this->hasOne(SeoDynamic::className(), [ 'seo_dynamic_id' => 'seo_dynamic_id' ]);
+ return $this->hasOne(SeoDynamic::className(), [ 'id' => 'seo_dynamic_id' ]);
}
}
diff --git a/common/models/SeoDynamicSearch.php b/common/models/SeoDynamicSearch.php
index d592d88..caa2505 100755
--- a/common/models/SeoDynamicSearch.php
+++ b/common/models/SeoDynamicSearch.php
@@ -27,7 +27,7 @@
return [
[
[
- 'seo_dynamic_id',
+ 'id',
'status',
],
'integer',
@@ -68,60 +68,74 @@
// add conditions that should always apply here
- $dataProvider = new ActiveDataProvider([
- 'query' => $query,
- 'sort' => [
- 'attributes' => [
- 'seo_dynamic_id',
- 'action',
- 'fields',
- 'status',
- 'param',
- 'title' => [
- 'asc' => [ 'seo_dynamic_lang.title' => SORT_ASC ],
- 'desc' => [ 'seo_dynamic_lang.title' => SORT_DESC ],
+ $dataProvider = new ActiveDataProvider(
+ [
+ 'query' => $query,
+ 'sort' => [
+ 'attributes' => [
+ 'id',
+ 'action',
+ 'fields',
+ 'status',
+ 'param',
+ 'title' => [
+ 'asc' => [ 'seo_dynamic_lang.title' => SORT_ASC ],
+ 'desc' => [ 'seo_dynamic_lang.title' => SORT_DESC ],
+ ],
],
],
- ],
- ]);
+ ]
+ );
$this->load($params);
- if(!$this->validate()) {
+ 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;
}
// grid filtering conditions
- $query->andWhere([
- 'seo_category_id' => $seo_category_id,
- ])
- ->andFilterWhere([
- 'seo_dynamic_id' => $this->seo_dynamic_id,
- 'status' => $this->status,
- ]);
+ $query->andWhere(
+ [
+ 'seo_category_id' => $seo_category_id,
+ ]
+ )
+ ->andFilterWhere(
+ [
+ 'id' => $this->id,
+ 'status' => $this->status,
+ ]
+ );
- $query->andFilterWhere([
- 'ilike',
- 'action',
- $this->action,
- ])
- ->andFilterWhere([
- 'ilike',
- 'fields',
- $this->fields,
- ])
- ->andFilterWhere([
- 'ilike',
- 'param',
- $this->param,
- ])
- ->andFilterWhere([
- 'ilike',
- 'seo_dynamic_lang.title',
- $this->title,
- ]);
+ $query->andFilterWhere(
+ [
+ 'ilike',
+ 'action',
+ $this->action,
+ ]
+ )
+ ->andFilterWhere(
+ [
+ 'ilike',
+ 'fields',
+ $this->fields,
+ ]
+ )
+ ->andFilterWhere(
+ [
+ 'ilike',
+ 'param',
+ $this->param,
+ ]
+ )
+ ->andFilterWhere(
+ [
+ 'ilike',
+ 'seo_dynamic_lang.title',
+ $this->title,
+ ]
+ );
return $dataProvider;
}
diff --git a/common/models/SeoLang.php b/common/models/SeoLang.php
index e0b8bde..c6da2f5 100755
--- a/common/models/SeoLang.php
+++ b/common/models/SeoLang.php
@@ -8,6 +8,7 @@
/**
* This is the model class for table "seo_lang".
+ *
* @property integer $seo_id
* @property integer $language_id
* @property string $title
@@ -83,7 +84,7 @@
'exist',
'skipOnError' => true,
'targetClass' => Seo::className(),
- 'targetAttribute' => [ 'seo_id' => 'seo_id' ],
+ 'targetAttribute' => [ 'seo_id' => 'id' ],
],
];
}
@@ -94,13 +95,13 @@
public function attributeLabels()
{
return [
- 'seo_id' => Yii::t('app', 'seo_id'),
- 'language_id' => Yii::t('app', 'language_id'),
- 'title' => Yii::t('app', 'title'),
+ 'seo_id' => Yii::t('app', 'seo_id'),
+ 'language_id' => Yii::t('app', 'language_id'),
+ 'title' => Yii::t('app', 'title'),
'meta_description' => Yii::t('app', 'meta_description'),
- 'h1' => Yii::t('app', 'h1'),
- 'meta' => Yii::t('app', 'meta'),
- 'seo_text' => Yii::t('app', 'seo_text'),
+ 'h1' => Yii::t('app', 'h1'),
+ 'meta' => Yii::t('app', 'meta'),
+ 'seo_text' => Yii::t('app', 'seo_text'),
];
}
@@ -117,6 +118,6 @@
*/
public function getSeo()
{
- return $this->hasOne(Seo::className(), [ 'seo_id' => 'seo_id' ]);
+ return $this->hasOne(Seo::className(), [ 'id' => 'seo_id' ]);
}
}
diff --git a/common/models/SeoSearch.php b/common/models/SeoSearch.php
index d73e065..28961f0 100755
--- a/common/models/SeoSearch.php
+++ b/common/models/SeoSearch.php
@@ -33,7 +33,7 @@
{
return [
[
- [ 'seo_id' ],
+ [ 'id' ],
'integer',
],
[
@@ -73,79 +73,95 @@
// add conditions that should always apply here
- $dataProvider = new ActiveDataProvider([
- 'query' => $query,
- 'sort' => [
- 'attributes' => [
- 'seo_id',
- 'url',
- 'title' => [
- 'asc' => [ 'seo_lang.title' => SORT_ASC ],
- 'desc' => [ 'seo_lang.title' => SORT_DESC ],
- ],
- 'meta_description' => [
- 'asc' => [ 'seo_lang.meta_description' => SORT_ASC ],
- 'desc' => [ 'seo_lang.meta_description' => SORT_DESC ],
- ],
- 'h1' => [
- 'asc' => [ 'seo_lang.h1' => SORT_ASC ],
- 'desc' => [ 'seo_lang.h1' => SORT_DESC ],
- ],
- 'meta' => [
- 'asc' => [ 'seo_lang.meta' => SORT_ASC ],
- 'desc' => [ 'seo_lang.meta' => SORT_DESC ],
- ],
- 'seo_text' => [
- 'asc' => [ 'seo_lang.seo_text' => SORT_ASC ],
- 'desc' => [ 'seo_lang.seo_text' => SORT_DESC ],
+ $dataProvider = new ActiveDataProvider(
+ [
+ 'query' => $query,
+ 'sort' => [
+ 'attributes' => [
+ 'id',
+ 'url',
+ 'title' => [
+ 'asc' => [ 'seo_lang.title' => SORT_ASC ],
+ 'desc' => [ 'seo_lang.title' => SORT_DESC ],
+ ],
+ 'meta_description' => [
+ 'asc' => [ 'seo_lang.meta_description' => SORT_ASC ],
+ 'desc' => [ 'seo_lang.meta_description' => SORT_DESC ],
+ ],
+ 'h1' => [
+ 'asc' => [ 'seo_lang.h1' => SORT_ASC ],
+ 'desc' => [ 'seo_lang.h1' => SORT_DESC ],
+ ],
+ 'meta' => [
+ 'asc' => [ 'seo_lang.meta' => SORT_ASC ],
+ 'desc' => [ 'seo_lang.meta' => SORT_DESC ],
+ ],
+ 'seo_text' => [
+ 'asc' => [ 'seo_lang.seo_text' => SORT_ASC ],
+ 'desc' => [ 'seo_lang.seo_text' => SORT_DESC ],
+ ],
],
],
- ],
- ]);
+ ]
+ );
$this->load($params);
- if(!$this->validate()) {
+ 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;
}
// grid filtering conditions
- $query->andFilterWhere([
- 'seo_id' => $this->seo_id,
- ]);
+ $query->andFilterWhere(
+ [
+ 'id' => $this->id,
+ ]
+ );
- $query->andFilterWhere([
- 'like',
- 'url',
- $this->url,
- ])
- ->andFilterWhere([
- 'ilike',
- 'seo_lang.title',
- $this->title,
- ])
- ->andFilterWhere([
- 'ilike',
- 'seo_lang.meta_description',
- $this->meta_description,
- ])
- ->andFilterWhere([
- 'ilike',
- 'seo_lang.h1',
- $this->h1,
- ])
- ->andFilterWhere([
- 'ilike',
- 'seo_lang.meta',
- $this->meta,
- ])
- ->andFilterWhere([
- 'ilike',
- 'seo_lang.seo_text',
- $this->seoText,
- ]);
+ $query->andFilterWhere(
+ [
+ 'like',
+ 'url',
+ $this->url,
+ ]
+ )
+ ->andFilterWhere(
+ [
+ 'ilike',
+ 'seo_lang.title',
+ $this->title,
+ ]
+ )
+ ->andFilterWhere(
+ [
+ 'ilike',
+ 'seo_lang.meta_description',
+ $this->meta_description,
+ ]
+ )
+ ->andFilterWhere(
+ [
+ 'ilike',
+ 'seo_lang.h1',
+ $this->h1,
+ ]
+ )
+ ->andFilterWhere(
+ [
+ 'ilike',
+ 'seo_lang.meta',
+ $this->meta,
+ ]
+ )
+ ->andFilterWhere(
+ [
+ 'ilike',
+ 'seo_lang.seo_text',
+ $this->seoText,
+ ]
+ );
return $dataProvider;
}
diff --git a/common/models/Service.php b/common/models/Service.php
index 30c2ed9..96d2cd3 100755
--- a/common/models/Service.php
+++ b/common/models/Service.php
@@ -12,7 +12,8 @@
/**
* This is the model class for table "service".
- * @property integer $service_id
+ *
+ * @property integer $id
* @property string $image
* @property integer $created_at
* @property integer $updated_at
@@ -98,7 +99,7 @@
public function attributeLabels()
{
return [
- 'service_id' => Yii::t('app', 'service_id'),
+ 'id' => Yii::t('app', 'service_id'),
'image' => Yii::t('app', 'image'),
'created_at' => Yii::t('app', 'created_at'),
'updated_at' => Yii::t('app', 'updated_at'),
diff --git a/common/models/ServiceLang.php b/common/models/ServiceLang.php
index 42dcc78..db024a1 100755
--- a/common/models/ServiceLang.php
+++ b/common/models/ServiceLang.php
@@ -8,6 +8,7 @@
/**
* This is the model class for table "service_lang".
+ *
* @property integer $service_id
* @property integer $language_id
* @property string $title
@@ -42,7 +43,7 @@
{
return [
'slug' => [
- 'class' => 'common\behaviors\Slug',
+ 'class' => 'common\behaviors\Slug',
],
];
}
@@ -101,7 +102,7 @@
'exist',
'skipOnError' => true,
'targetClass' => Service::className(),
- 'targetAttribute' => [ 'service_id' => 'service_id' ],
+ 'targetAttribute' => [ 'service_id' => 'id' ],
],
];
}
@@ -112,14 +113,14 @@
public function attributeLabels()
{
return [
- 'service_id' => Yii::t('app', 'service_id'),
- 'language_id' => Yii::t('app', 'language_id'),
- 'title' => Yii::t('app', 'name'),
- 'body' => Yii::t('app', 'body'),
- 'seo_text' => Yii::t('app', 'seo_text'),
- 'meta_title' => Yii::t('app', 'meta_title'),
+ 'service_id' => Yii::t('app', 'service_id'),
+ 'language_id' => Yii::t('app', 'language_id'),
+ 'title' => Yii::t('app', 'name'),
+ 'body' => Yii::t('app', 'body'),
+ 'seo_text' => Yii::t('app', 'seo_text'),
+ 'meta_title' => Yii::t('app', 'meta_title'),
'meta_description' => Yii::t('app', 'meta_description'),
- 'h1' => Yii::t('app', 'h1'),
+ 'h1' => Yii::t('app', 'h1'),
];
}
@@ -136,6 +137,6 @@
*/
public function getService()
{
- return $this->hasOne(Service::className(), [ 'service_id' => 'service_id' ]);
+ return $this->hasOne(Service::className(), [ 'id' => 'service_id' ]);
}
}
diff --git a/common/models/ServiceSearch.php b/common/models/ServiceSearch.php
index e4ca391..1561e72 100755
--- a/common/models/ServiceSearch.php
+++ b/common/models/ServiceSearch.php
@@ -24,7 +24,7 @@
return [
[
[
- 'service_id',
+ 'id',
'created_at',
'updated_at',
],
@@ -55,24 +55,28 @@
// add conditions that should always apply here
- $dataProvider = new ActiveDataProvider([
- 'query' => $query,
- ]);
+ $dataProvider = new ActiveDataProvider(
+ [
+ 'query' => $query,
+ ]
+ );
$this->load($params);
- if(!$this->validate()) {
+ 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;
}
// grid filtering conditions
- $query->andFilterWhere([
- 'service_id' => $this->service_id,
- 'created_at' => $this->created_at,
- 'updated_at' => $this->updated_at,
- ]);
+ $query->andFilterWhere(
+ [
+ 'id' => $this->id,
+ 'created_at' => $this->created_at,
+ 'updated_at' => $this->updated_at,
+ ]
+ );
return $dataProvider;
}
diff --git a/common/models/Slider.php b/common/models/Slider.php
index 52eacbe..fc2cd5d 100755
--- a/common/models/Slider.php
+++ b/common/models/Slider.php
@@ -7,13 +7,14 @@
/**
* This is the model class for table "slider".
- * @property integer $slider_id
- * @property integer $speed
- * @property integer $duration
- * @property string $title
- * @property integer $status
- * @property integer $width
- * @property integer $height
+ *
+ * @property integer $id
+ * @property integer $speed
+ * @property integer $duration
+ * @property string $title
+ * @property integer $status
+ * @property integer $width
+ * @property integer $height
* @property SliderImage[] $sliderImage
*/
class Slider extends ActiveRecord
@@ -60,9 +61,13 @@
'title',
'unique',
'targetClass' => '\common\models\Slider',
- 'message' => Yii::t('app', 'message', [
- 'field' => 'Title',
- ]),
+ 'message' => Yii::t(
+ 'app',
+ 'message',
+ [
+ 'field' => 'Title',
+ ]
+ ),
],
];
}
@@ -73,13 +78,13 @@
public function attributeLabels()
{
return [
- 'slider_id' => Yii::t('app', 'slider_id'),
- 'speed' => Yii::t('app', 'speed'),
- 'duration' => Yii::t('app', 'duration'),
- 'title' => Yii::t('app', 'title'),
- 'status' => Yii::t('app', 'status'),
- 'width' => Yii::t('app', 'width'),
- 'height' => Yii::t('app', 'height'),
+ 'id' => Yii::t('app', 'slider_id'),
+ 'speed' => Yii::t('app', 'speed'),
+ 'duration' => Yii::t('app', 'duration'),
+ 'title' => Yii::t('app', 'title'),
+ 'status' => Yii::t('app', 'status'),
+ 'width' => Yii::t('app', 'width'),
+ 'height' => Yii::t('app', 'height'),
];
}
@@ -88,7 +93,7 @@
*/
public function getSliderImage()
{
- return $this->hasMany(SliderImage::className(), [ 'slider_id' => 'slider_id' ])
+ return $this->hasMany(SliderImage::className(), [ 'slider_id' => 'id' ])
->where([ SliderImage::tableName() . '.status' => 1 ]);
}
diff --git a/common/models/SliderImage.php b/common/models/SliderImage.php
index d20ae98..a7bff7e 100755
--- a/common/models/SliderImage.php
+++ b/common/models/SliderImage.php
@@ -11,7 +11,8 @@
/**
* This is the model class for table "slider_image".
- * @property integer $slider_image_id
+ *
+ * @property integer $id
* @property integer $slider_id
* @property string $image
* @property string $url
@@ -82,7 +83,7 @@
'exist',
'skipOnError' => true,
'targetClass' => Slider::className(),
- 'targetAttribute' => [ 'slider_id' => 'slider_id' ],
+ 'targetAttribute' => [ 'slider_id' => 'id' ],
],
];
}
@@ -111,12 +112,12 @@
public function attributeLabels()
{
return [
- 'slider_image_id' => Yii::t('app', 'slider_image_id'),
- 'slider_id' => Yii::t('app', 'slider_id'),
- 'image' => Yii::t('app', 'image'),
- 'url' => Yii::t('app', 'url'),
- 'status' => Yii::t('app', 'status'),
- 'sort' => Yii::t('app', 'sort'),
+ 'id' => Yii::t('app', 'slider_image_id'),
+ 'slider_id' => Yii::t('app', 'slider_id'),
+ 'image' => Yii::t('app', 'image'),
+ 'url' => Yii::t('app', 'url'),
+ 'status' => Yii::t('app', 'status'),
+ 'sort' => Yii::t('app', 'sort'),
];
}
@@ -125,7 +126,7 @@
*/
public function getSlider()
{
- return $this->hasOne(Slider::className(), [ 'slider_id' => 'slider_id' ]);
+ return $this->hasOne(Slider::className(), [ 'id' => 'slider_id' ]);
}
}
diff --git a/common/models/SliderImageLang.php b/common/models/SliderImageLang.php
index 3673edf..20d3397 100755
--- a/common/models/SliderImageLang.php
+++ b/common/models/SliderImageLang.php
@@ -8,6 +8,7 @@
/**
* This is the model class for table "slider_image_lang".
+ *
* @property integer $slider_image_id
* @property integer $language_id
* @property string $title
@@ -72,7 +73,7 @@
'exist',
'skipOnError' => true,
'targetClass' => SliderImage::className(),
- 'targetAttribute' => [ 'slider_image_id' => 'slider_image_id' ],
+ 'targetAttribute' => [ 'slider_image_id' => 'id' ],
],
];
}
@@ -103,6 +104,6 @@
*/
public function getSliderImage()
{
- return $this->hasOne(SliderImage::className(), [ 'slider_image_id' => 'slider_image_id' ]);
+ return $this->hasOne(SliderImage::className(), [ 'id' => 'slider_image_id' ]);
}
}
diff --git a/common/models/SliderImageSearch.php b/common/models/SliderImageSearch.php
index 19f777f..7a7ca9e 100755
--- a/common/models/SliderImageSearch.php
+++ b/common/models/SliderImageSearch.php
@@ -25,7 +25,7 @@
return [
[
[
- 'slider_image_id',
+ 'id',
'slider_id',
'status',
'sort',
@@ -64,31 +64,37 @@
// add conditions that should always apply here
- $dataProvider = new ActiveDataProvider([
- 'query' => $query,
- ]);
+ $dataProvider = new ActiveDataProvider(
+ [
+ 'query' => $query,
+ ]
+ );
$this->load($params);
- if(!$this->validate()) {
+ 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;
}
// grid filtering conditions
- $query->andFilterWhere([
- 'slider_image_id' => $this->slider_image_id,
- 'slider_id' => $slider_id,
- 'status' => $this->status,
- 'sort' => $this->sort,
- ]);
+ $query->andFilterWhere(
+ [
+ 'id' => $this->id,
+ 'slider_id' => $slider_id,
+ 'status' => $this->status,
+ 'sort' => $this->sort,
+ ]
+ );
- $query->andFilterWhere([
- 'like',
- 'url',
- $this->url,
- ]);
+ $query->andFilterWhere(
+ [
+ 'like',
+ 'url',
+ $this->url,
+ ]
+ );
return $dataProvider;
}
diff --git a/common/models/SliderSearch.php b/common/models/SliderSearch.php
index 180796b..77a4630 100755
--- a/common/models/SliderSearch.php
+++ b/common/models/SliderSearch.php
@@ -21,7 +21,7 @@
return [
[
[
- 'slider_id',
+ 'id',
'status',
],
'integer',
@@ -55,29 +55,35 @@
// add conditions that should always apply here
- $dataProvider = new ActiveDataProvider([
- 'query' => $query,
- ]);
+ $dataProvider = new ActiveDataProvider(
+ [
+ 'query' => $query,
+ ]
+ );
$this->load($params);
- if(!$this->validate()) {
+ 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;
}
// grid filtering conditions
- $query->andFilterWhere([
- 'slider_id' => $this->slider_id,
- 'status' => $this->status,
- ]);
+ $query->andFilterWhere(
+ [
+ 'id' => $this->id,
+ 'status' => $this->status,
+ ]
+ );
- $query->andFilterWhere([
- 'like',
- 'title',
- $this->title,
- ]);
+ $query->andFilterWhere(
+ [
+ 'like',
+ 'title',
+ $this->title,
+ ]
+ );
return $dataProvider;
}
diff --git a/common/modules/product/controllers/ManageController.php b/common/modules/product/controllers/ManageController.php
index 3c5e55f..ec2b985 100755
--- a/common/modules/product/controllers/ManageController.php
+++ b/common/modules/product/controllers/ManageController.php
@@ -39,6 +39,7 @@
/**
* Lists all Product models.
+ *
* @return mixed
*/
public function actionIndex()
@@ -46,10 +47,13 @@
$searchModel = new ProductSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
- return $this->render('index', [
- 'searchModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- ]);
+ return $this->render(
+ 'index',
+ [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ ]
+ );
}
/**
@@ -69,17 +73,21 @@
->with('lang')
->all();
$properties = $model->getProperties();
- return $this->render('view', [
- 'model' => $this->findModel($id),
- 'categories' => $categories,
- 'variants' => $variants,
- 'properties' => $properties,
- ]);
+ return $this->render(
+ 'view',
+ [
+ 'model' => $this->findModel($id),
+ 'categories' => $categories,
+ 'variants' => $variants,
+ 'properties' => $properties,
+ ]
+ );
}
/**
* Creates a new Product model.
* If creation is successful, the browser will be redirected to the 'view' page.
+ *
* @return mixed
*/
public function actionCreate()
@@ -87,19 +95,24 @@
$model = new Product();
$model->detachBehavior('techSpec');
$model->generateLangs();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
$model->loadLangs(\Yii::$app->request);
- if($model->save() && $model->transactionStatus) {
- return $this->redirect([
- 'view',
- 'id' => $model->id,
- ]);
+ if ($model->save() && $model->transactionStatus) {
+ return $this->redirect(
+ [
+ 'view',
+ 'id' => $model->id,
+ ]
+ );
}
}
- return $this->render('create', [
- 'model' => $model,
- 'modelLangs' => $model->modelLangs,
- ]);
+ return $this->render(
+ 'create',
+ [
+ 'model' => $model,
+ 'modelLangs' => $model->modelLangs,
+ ]
+ );
}
/**
@@ -114,24 +127,29 @@
{
$model = $this->findModel($id);
$model->generateLangs();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
$model->loadLangs(\Yii::$app->request);
- if($model->save() && $model->transactionStatus) {
- return $this->redirect([
- 'view',
- 'id' => $model->id,
- ]);
+ if ($model->save() && $model->transactionStatus) {
+ return $this->redirect(
+ [
+ 'view',
+ 'id' => $model->id,
+ ]
+ );
}
}
/**
* @var ActiveQuery $groups
*/
$groups = $model->getTaxGroupsByLevel(0);
- return $this->render('update', [
- 'model' => $model,
- 'modelLangs' => $model->modelLangs,
- 'groups' => $groups,
- ]);
+ return $this->render(
+ 'update',
+ [
+ 'model' => $model,
+ 'modelLangs' => $model->modelLangs,
+ 'groups' => $groups,
+ ]
+ );
}
/**
@@ -153,7 +171,7 @@
{
$image = ProductImage::findOne($id);
- if($image) {
+ if ($image) {
$image->delete();
}
@@ -183,13 +201,13 @@
return $this->redirect([ 'index' ]);
}
- public function actionAkciya($id)
+ public function actionIsDiscount($id)
{
$model = $this->findModel($id);
- $model->akciya = intval(empty( $model->akciya ));
+ $model->is_discount = intval(empty( $model->is_discount ));
- $model->save(false, [ 'akciya' ]);
+ $model->save(false, [ 'is_discount' ]);
return $this->redirect([ 'index' ]);
}
@@ -199,43 +217,51 @@
$model = new Import();
$languages = Language::find()
- ->select([
- 'name',
- 'id',
- ])
+ ->select(
+ [
+ 'name',
+ 'id',
+ ]
+ )
->where([ 'status' => 1 ])
->orderBy([ 'default' => SORT_DESC ])
->asArray()
->indexBy('id')
->column();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
\Yii::$app->session->set('export_lang', $model->lang);
$file = UploadedFile::getInstances($model, 'file');
$method = 'go' . ucfirst($model->type);
$target = Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFile' . ucfirst($model->type));
- if(empty( $file )) {
+ if (empty( $file )) {
$model->errors[] = 'File not upload';
- } elseif($method == 'goPrices' && $file[ 0 ]->name != 'file_1.csv') {
+ } elseif ($method == 'goPrices' && $file[ 0 ]->name != 'file_1.csv') {
$model->errors[] = 'File need "file_1.csv"';
- } elseif($method == 'goProducts' && $file[ 0 ]->name == 'file_1.csv') {
+ } elseif ($method == 'goProducts' && $file[ 0 ]->name == 'file_1.csv') {
$model->errors[] = 'File can not "file_1.csv"';
- } elseif($model->validate() && $file[ 0 ]->saveAs($target)) {
+ } elseif ($model->validate() && $file[ 0 ]->saveAs($target)) {
// PROCESS PAGE
- return $this->render('import-process', [
- 'model' => $model,
- 'method' => $model->type,
- 'target' => $target,
- ]);
+ return $this->render(
+ 'import-process',
+ [
+ 'model' => $model,
+ 'method' => $model->type,
+ 'target' => $target,
+ ]
+ );
} else {
$model->errors[] = 'File can not be upload or other error';
}
}
- return $this->render('import', [
- 'model' => $model,
- 'languages' => $languages,
- ]);
+ return $this->render(
+ 'import',
+ [
+ 'model' => $model,
+ 'languages' => $languages,
+ ]
+ );
}
public function actionProducts()
@@ -244,7 +270,7 @@
$model = new Import();
- if(Yii::$app->request->isAjax) {
+ if (Yii::$app->request->isAjax) {
Yii::$app->response->format = Response::FORMAT_JSON;
return $model->goProducts($from, 1);
} else {
@@ -258,7 +284,7 @@
$model = new Import();
- if(Yii::$app->request->isAjax) {
+ if (Yii::$app->request->isAjax) {
Yii::$app->response->format = Response::FORMAT_JSON;
return $model->goPrices($from, 10);
} else {
@@ -270,7 +296,7 @@
{
$model = new Export();
- if(Yii::$app->request->isAjax) {
+ if (Yii::$app->request->isAjax) {
Yii::$app->response->format = Response::FORMAT_JSON;
return $model->process($filename, $from);
} else {
@@ -282,17 +308,23 @@
{
$model = new Export();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
\Yii::$app->session->set('export_lang', $model->lang);
- return $this->render('export-process', [
- 'model' => $model,
- 'method' => 'export',
- ]);
+ return $this->render(
+ 'export-process',
+ [
+ 'model' => $model,
+ 'method' => 'export',
+ ]
+ );
}
- return $this->render('export', [
- 'model' => $model,
- ]);
+ return $this->render(
+ 'export',
+ [
+ 'model' => $model,
+ ]
+ );
}
/**
@@ -306,10 +338,10 @@
*/
protected function findModel($id)
{
- if(( $model = Product::find()
- ->where([ 'id' => $id ])
- ->with('lang')
- ->one() ) !== NULL
+ if (( $model = Product::find()
+ ->where([ 'id' => $id ])
+ ->with('lang')
+ ->one() ) !== null
) {
return $model;
} else {
diff --git a/common/modules/product/controllers/ProductUnitController.php b/common/modules/product/controllers/ProductUnitController.php
index 13d6b77..bf0d6b8 100755
--- a/common/modules/product/controllers/ProductUnitController.php
+++ b/common/modules/product/controllers/ProductUnitController.php
@@ -32,6 +32,7 @@
/**
* Lists all ProductUnit models.
+ *
* @return mixed
*/
public function actionIndex()
@@ -39,10 +40,13 @@
$searchModel = new ProductUnitSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
- return $this->render('index', [
- 'searchModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- ]);
+ return $this->render(
+ 'index',
+ [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ ]
+ );
}
/**
@@ -54,33 +58,42 @@
*/
public function actionView($id)
{
- return $this->render('view', [
- 'model' => $this->findModel($id),
- ]);
+ return $this->render(
+ 'view',
+ [
+ 'model' => $this->findModel($id),
+ ]
+ );
}
/**
* Creates a new ProductUnit model.
* If creation is successful, the browser will be redirected to the 'view' page.
+ *
* @return mixed
*/
public function actionCreate()
{
$model = new ProductUnit();
$model->generateLangs();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
$model->loadLangs(\Yii::$app->request);
- if($model->save() && $model->transactionStatus) {
- return $this->redirect([
- 'view',
- 'id' => $model->product_unit_id,
- ]);
+ if ($model->save() && $model->transactionStatus) {
+ return $this->redirect(
+ [
+ 'view',
+ 'id' => $model->id,
+ ]
+ );
}
}
- return $this->render('create', [
- 'model' => $model,
- 'modelLangs' => $model->modelLangs,
- ]);
+ return $this->render(
+ 'create',
+ [
+ 'model' => $model,
+ 'modelLangs' => $model->modelLangs,
+ ]
+ );
}
/**
@@ -95,19 +108,24 @@
{
$model = $this->findModel($id);
$model->generateLangs();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
$model->loadLangs(\Yii::$app->request);
- if($model->save() && $model->transactionStatus) {
- return $this->redirect([
- 'view',
- 'id' => $model->product_unit_id,
- ]);
+ if ($model->save() && $model->transactionStatus) {
+ return $this->redirect(
+ [
+ 'view',
+ 'id' => $model->id,
+ ]
+ );
}
}
- return $this->render('update', [
- 'model' => $model,
- 'modelLangs' => $model->modelLangs,
- ]);
+ return $this->render(
+ 'update',
+ [
+ 'model' => $model,
+ 'modelLangs' => $model->modelLangs,
+ ]
+ );
}
/**
@@ -137,10 +155,10 @@
*/
protected function findModel($id)
{
- if(( $model = ProductUnit::find()
- ->where([ 'product_unit_id' => $id ])
- ->with('lang')
- ->one() ) !== NULL
+ if (( $model = ProductUnit::find()
+ ->where([ 'id' => $id ])
+ ->with('lang')
+ ->one() ) !== null
) {
return $model;
} else {
diff --git a/common/modules/product/controllers/VariantController.php b/common/modules/product/controllers/VariantController.php
index 02acb53..c22ecde 100755
--- a/common/modules/product/controllers/VariantController.php
+++ b/common/modules/product/controllers/VariantController.php
@@ -54,11 +54,14 @@
$query->with('image')
->andWhere([ 'product_id' => $product->id ]);
- return $this->render('index', [
- 'searchModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- 'product' => $product,
- ]);
+ return $this->render(
+ 'index',
+ [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ 'product' => $product,
+ ]
+ );
}
/**
@@ -72,10 +75,13 @@
{
$model = $this->findModel($id);
$properties = $model->getProperties();
- return $this->render('view', [
- 'model' => $model,
- 'properties' => $properties,
- ]);
+ return $this->render(
+ 'view',
+ [
+ 'model' => $model,
+ 'properties' => $properties,
+ ]
+ );
}
/**
@@ -92,17 +98,17 @@
$model = new ProductVariant();
$model->product_id = $product->id;
$model->generateLangs();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
$model->loadLangs(\Yii::$app->request);
- if($model->save() && $model->transactionStatus) {
+ if ($model->save() && $model->transactionStatus) {
$ProductStocks = Yii::$app->request->post('ProductStock');
$total_quantity = 0;
- if(!empty( $ProductStocks ) && is_array($ProductStocks)) {
+ if (!empty( $ProductStocks ) && is_array($ProductStocks)) {
$model->unlinkAll('stocks', true);
$sorted_array = [];
- foreach($ProductStocks as $subArray) {
- if(!empty( $subArray[ 'title' ] ) && !empty( $subArray[ 'quantity' ] )) {
- if(!empty( $sorted_array[ $subArray[ 'title' ] ] )) {
+ foreach ($ProductStocks as $subArray) {
+ if (!empty( $subArray[ 'title' ] ) && !empty( $subArray[ 'quantity' ] )) {
+ if (!empty( $sorted_array[ $subArray[ 'title' ] ] )) {
$sorted_array[ $subArray[ 'title' ] ] += $subArray[ 'quantity' ];
} else {
$sorted_array[ $subArray[ 'title' ] ] = $subArray[ 'quantity' ];
@@ -115,25 +121,28 @@
->where([ 'title' => $stock_names ])
->indexBy('title')
->all();
- foreach($ProductStocks as $name => $quantity) {
+ foreach ($ProductStocks as $name => $quantity) {
$quantity = (int) $quantity;
- if(!array_key_exists($name, $stocks)) {
- $stock = new Stock([
- 'title' => $name,
- ]);
- if(!$stock->save()) {
+ if (!array_key_exists($name, $stocks)) {
+ $stock = new Stock(
+ [
+ 'title' => $name,
+ ]
+ );
+ if (!$stock->save()) {
continue;
}
} else {
$stock = $stocks[ $name ];
}
- $psModel = new ProductStock([
- 'product_id' => $model->product_id,
- 'product_variant_id' => $model->product_variant_id,
- 'stock_id' => $stock->stock_id,
- 'quantity' => $quantity,
- ]);
- if($psModel->save()) {
+ $psModel = new ProductStock(
+ [
+ 'product_variant_id' => $model->id,
+ 'stock_id' => $stock->id,
+ 'quantity' => $quantity,
+ ]
+ );
+ if ($psModel->save()) {
$total_quantity += $quantity;
}
}
@@ -142,22 +151,27 @@
}
$model->stock = $total_quantity;
- if($model->save() && $model->transactionStatus) {
- return $this->redirect([
- 'index',
- 'product_id' => $product->id,
- ]);
+ if ($model->save() && $model->transactionStatus) {
+ return $this->redirect(
+ [
+ 'index',
+ 'product_id' => $product->id,
+ ]
+ );
}
}
}
$groups = $model->getTaxGroupsByLevel(1);
- return $this->render('create', [
- 'model' => $model,
- 'modelLangs' => $model->modelLangs,
- 'groups' => $groups,
- 'stocks' => [ new ProductStock() ],
- 'product' => $product,
- ]);
+ return $this->render(
+ 'create',
+ [
+ 'model' => $model,
+ 'modelLangs' => $model->modelLangs,
+ 'groups' => $groups,
+ 'stocks' => [ new ProductStock() ],
+ 'product' => $product,
+ ]
+ );
}
/**
@@ -174,17 +188,17 @@
$product = $this->findProduct($product_id);
$model = $this->findModel($id);
$model->generateLangs();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
$model->loadLangs(\Yii::$app->request);
- if($model->save() && $model->transactionStatus) {
+ if ($model->save() && $model->transactionStatus) {
$ProductStocks = Yii::$app->request->post('ProductStock');
$total_quantity = 0;
- if(!empty( $ProductStocks ) && is_array($ProductStocks)) {
+ if (!empty( $ProductStocks ) && is_array($ProductStocks)) {
$model->unlinkAll('stocks', true);
$sorted_array = [];
- foreach($ProductStocks as $subArray) {
- if(!empty( $subArray[ 'title' ] ) && !empty( $subArray[ 'quantity' ] )) {
- if(!empty( $sorted_array[ $subArray[ 'title' ] ] )) {
+ foreach ($ProductStocks as $subArray) {
+ if (!empty( $subArray[ 'title' ] ) && !empty( $subArray[ 'quantity' ] )) {
+ if (!empty( $sorted_array[ $subArray[ 'title' ] ] )) {
$sorted_array[ $subArray[ 'title' ] ] += $subArray[ 'quantity' ];
} else {
$sorted_array[ $subArray[ 'title' ] ] = $subArray[ 'quantity' ];
@@ -197,25 +211,28 @@
->where([ 'title' => $stock_names ])
->indexBy('title')
->all();
- foreach($ProductStocks as $name => $quantity) {
+ foreach ($ProductStocks as $name => $quantity) {
$quantity = (int) $quantity;
- if(!array_key_exists($name, $stocks)) {
- $stock = new Stock([
- 'title' => $name,
- ]);
- if(!$stock->save()) {
+ if (!array_key_exists($name, $stocks)) {
+ $stock = new Stock(
+ [
+ 'title' => $name,
+ ]
+ );
+ if (!$stock->save()) {
continue;
}
} else {
$stock = $stocks[ $name ];
}
- $psModel = new ProductStock([
- 'product_id' => $model->product_id,
- 'product_variant_id' => $model->product_variant_id,
- 'stock_id' => $stock->stock_id,
- 'quantity' => $quantity,
- ]);
- if($psModel->save()) {
+ $psModel = new ProductStock(
+ [
+ 'product_variant_id' => $model->id,
+ 'stock_id' => $stock->id,
+ 'quantity' => $quantity,
+ ]
+ );
+ if ($psModel->save()) {
$total_quantity += $quantity;
}
}
@@ -223,22 +240,27 @@
$model->unlinkAll('stocks', true);
}
$model->stock = $total_quantity;
- if($model->save() && $model->transactionStatus) {
- return $this->redirect([
- 'index',
- 'product_id' => $product_id,
- ]);
+ if ($model->save() && $model->transactionStatus) {
+ return $this->redirect(
+ [
+ 'index',
+ 'product_id' => $product_id,
+ ]
+ );
}
}
}
$groups = $model->getTaxGroupsByLevel(1);
- return $this->render('update', [
- 'model' => $model,
- 'modelLangs' => $model->modelLangs,
- 'groups' => $groups,
- 'stocks' => ( !empty( $model->variantStocks ) ) ? $model->variantStocks : [ new ProductStock ],
- 'product' => $product,
- ]);
+ return $this->render(
+ 'update',
+ [
+ 'model' => $model,
+ 'modelLangs' => $model->modelLangs,
+ 'groups' => $groups,
+ 'stocks' => ( !empty( $model->variantStocks ) ) ? $model->variantStocks : [ new ProductStock ],
+ 'product' => $product,
+ ]
+ );
}
/**
@@ -256,17 +278,19 @@
$this->findModel($id)
->delete();
- return $this->redirect([
- 'index',
- 'product_id' => $product_id,
- ]);
+ return $this->redirect(
+ [
+ 'index',
+ 'product_id' => $product_id,
+ ]
+ );
}
public function actionDelimg($id)
{
$image = ProductImage::findOne($id);
- if($image) {
+ if ($image) {
$image->delete();
}
@@ -285,10 +309,10 @@
*/
protected function findModel($id)
{
- if(( $model = ProductVariant::find()
- ->where([ 'product_variant_id' => $id ])
- ->with('lang')
- ->one() ) !== NULL
+ if (( $model = ProductVariant::find()
+ ->where([ 'id' => $id ])
+ ->with('lang')
+ ->one() ) !== null
) {
return $model;
} else {
@@ -304,10 +328,10 @@
*/
protected function findProduct($product_id)
{
- if(( $model = Product::find()
- ->with('lang')
- ->where([ 'id' => $product_id ])
- ->one() ) !== NULL
+ if (( $model = Product::find()
+ ->with('lang')
+ ->where([ 'id' => $product_id ])
+ ->one() ) !== null
) {
return $model;
} else {
diff --git a/common/modules/product/helpers/ProductHelper.php b/common/modules/product/helpers/ProductHelper.php
index 5d118b9..cd88ab8 100755
--- a/common/modules/product/helpers/ProductHelper.php
+++ b/common/modules/product/helpers/ProductHelper.php
@@ -20,7 +20,7 @@
public static function getCategories()
{
return Category::find()
- ->getTree(NULL, 'lang');
+ ->getTree(null, 'lang');
}
public static function getBrands()
@@ -37,32 +37,40 @@
public static function getFilterForOption($filter, $key, $value, $remove = false)
{
$result = $filter;
- if(is_array($value)) {
- foreach($value as $value_key => $value_items) {
- if(!is_array($value_items)) {
+ if (is_array($value)) {
+ foreach ($value as $value_key => $value_items) {
+ if (!is_array($value_items)) {
$value_items = [ $value_items ];
}
- foreach($value_items as $value_item) {
- if($remove && isset( $result[ $key ] ) && ( $i = array_search($value_item, $result[ $key ][ $value_key ]) ) !== false) {
+ foreach ($value_items as $value_item) {
+ if ($remove && isset( $result[ $key ] ) && ( $i = array_search(
+ $value_item,
+ $result[ $key ][ $value_key ]
+ ) ) !== false
+ ) {
unset( $result[ $key ][ $value_key ][ $i ] );
- if(empty( $result[ $key ][ $value_key ] )) {
+ if (empty( $result[ $key ][ $value_key ] )) {
unset( $result[ $key ][ $value_key ] );
}
} else {
- if(!isset( $result[ $key ][ $value_key ] ) || array_search($value_item, $result[ $key ][ $value_key ]) === false) {
+ if (!isset( $result[ $key ][ $value_key ] ) || array_search(
+ $value_item,
+ $result[ $key ][ $value_key ]
+ ) === false
+ ) {
$result[ $key ][ $value_key ][] = $value_item;
}
}
}
}
} else {
- if($remove && isset( $result[ $key ] ) && ( $i = array_search($value, $result[ $key ]) ) !== false) {
+ if ($remove && isset( $result[ $key ] ) && ( $i = array_search($value, $result[ $key ]) ) !== false) {
unset( $result[ $key ][ $i ] );
- if(empty( $result[ $key ] )) {
+ if (empty( $result[ $key ] )) {
unset( $result[ $key ] );
}
} else {
- if(!isset( $result[ $key ] ) || array_search($value, $result[ $key ]) === false) {
+ if (!isset( $result[ $key ] ) || array_search($value, $result[ $key ]) === false) {
$result[ $key ][] = $value;
}
}
@@ -73,9 +81,9 @@
public static function addLastProsucts($product_id)
{
$last_products = self::getLastProducts();
- if(!in_array($product_id, $last_products)) {
+ if (!in_array($product_id, $last_products)) {
$last_products[] = intval($product_id);
- if(count($last_products) > 16) {
+ if (count($last_products) > 16) {
array_shift($last_products);
}
Yii::$app->session->set('last_products', $last_products);
@@ -85,24 +93,26 @@
public static function getLastProducts($as_object = false)
{
$last_products = Yii::$app->session->get('last_products', []);
- if($as_object) {
+ if ($as_object) {
$last_products = Product::find()
->joinWith([ 'variant' ])
->where([ Product::tableName() . '.id' => $last_products ])
- ->andWhere([
- '!=',
- ProductVariant::tableName() . '.stock',
- 0,
- ])
+ ->andWhere(
+ [
+ '!=',
+ ProductVariant::tableName() . '.stock',
+ 0,
+ ]
+ )
->all();
}
return array_reverse($last_products);
}
- public static function getSpecialProducts($type, $count, $sort = NULL)
+ public static function getSpecialProducts($type, $count, $sort = null)
{
$data = [];
- switch($type) {
+ switch ($type) {
case 'top':
$data = [ 'is_top' => true ];
break;
@@ -110,18 +120,20 @@
$data = [ 'is_new' => true ];
break;
case 'promo':
- $data = [ 'akciya' => true ];
+ $data = [ 'is_discount' => true ];
break;
}
return Product::find()
->with('lang')
->joinWith('variants.lang')
->where($data)
- ->andWhere([
- '!=',
- ProductVariant::tableName() . '.stock',
- 0,
- ])
+ ->andWhere(
+ [
+ '!=',
+ ProductVariant::tableName() . '.stock',
+ 0,
+ ]
+ )
->limit($count)
->all();
}
@@ -134,51 +146,58 @@
*/
public static function getSimilarProducts($product, $count = 10)
{
- if(!is_object($product)) {
+ if (!is_object($product)) {
$product = Product::find()
->where([ 'id' => $product ])
->with('enabledVariants')
->one();
}
- if(!$product->properties) {
+ if (!$product->properties) {
return [];
}
$product_categories = [];
- foreach($product->categories as $category) {
+ foreach ($product->categories as $category) {
$product_categories[] = $category->id;
}
$query = Product::find()
->select('product.id')
->innerJoinWith('variant')
->joinWith('category')
- ->where([
- '!=',
- 'product_variant.stock',
- 0,
- ])
+ ->where(
+ [
+ '!=',
+ 'product_variant.stock',
+ 0,
+ ]
+ )
->andWhere([ 'product_category.category_id' => $product_categories ]);
- foreach($product->properties as $group) {
+ foreach ($product->properties as $group) {
$where = [];
- foreach($group->options as $option) {
+ foreach ($group->options as $option) {
$where[] = $option->tax_option_id;
}
- if(!$where) {
+ if (!$where) {
continue;
}
- $query->innerJoin('product_option to' . $group->tax_group_id, 'to' . $group->tax_group_id . '.product_id = product.id');
+ $query->innerJoin(
+ 'product_option to' . $group->tax_group_id,
+ 'to' . $group->tax_group_id . '.product_id = product.id'
+ );
$query->andWhere([ 'to' . $group->tax_group_id . '.option_id' => $where ]);
}
- $query->andWhere([
- '!=',
- 'product.id',
- $product->id,
- ]);
+ $query->andWhere(
+ [
+ '!=',
+ 'product.id',
+ $product->id,
+ ]
+ );
$query->groupBy('product.id');
$query->limit($count);
$products = $query->asArray()
->all();
- foreach($products as &$_product) {
+ foreach ($products as &$_product) {
$_product = Product::findOne($_product[ 'id' ]);
}
return $products;
@@ -193,39 +212,47 @@
*/
public static function setQueryParams(&$query, $params, $setPriceLimits = true)
{
- if(!empty( $params[ 'keywords' ] )) {
- if(!is_array($params[ 'keywords' ])) {
+ if (!empty( $params[ 'keywords' ] )) {
+ if (!is_array($params[ 'keywords' ])) {
$params[ 'keywords' ] = [ $params[ 'keywords' ] ];
}
- foreach($params[ 'keywords' ] as $keyword) {
- $query->orFilterWhere([
- 'ilike',
- Product::tableName() . '.name',
- $keyword,
- ]);
- $query->orFilterWhere([
- 'ilike',
- Brand::tableName() . '.name',
- $keyword,
- ]);
- $query->orFilterWhere([
- 'ilike',
- Category::tableName() . '.name',
- $keyword,
- ]);
- $query->orFilterWhere([
- 'ilike',
- ProductVariant::tableName() . '.sku',
- $keyword,
- ]);
+ foreach ($params[ 'keywords' ] as $keyword) {
+ $query->orFilterWhere(
+ [
+ 'ilike',
+ Product::tableName() . '.name',
+ $keyword,
+ ]
+ );
+ $query->orFilterWhere(
+ [
+ 'ilike',
+ Brand::tableName() . '.name',
+ $keyword,
+ ]
+ );
+ $query->orFilterWhere(
+ [
+ 'ilike',
+ Category::tableName() . '.name',
+ $keyword,
+ ]
+ );
+ $query->orFilterWhere(
+ [
+ 'ilike',
+ ProductVariant::tableName() . '.sku',
+ $keyword,
+ ]
+ );
}
}
- foreach($params as $key => $param) {
+ foreach ($params as $key => $param) {
- switch($key) {
+ switch ($key) {
case 'special':
- foreach($param as $inner_key => $value) {
+ foreach ($param as $inner_key => $value) {
$query->orFilterWhere([ Product::tableName() . '.' . $inner_key => $value ]);
}
break;
@@ -235,42 +262,54 @@
case 'keywords':
break;
case 'prices':
- if($param[ 'min' ] > 0) {
- $query->andWhere([
- '>=',
- ProductVariant::tableName() . '.price',
- $param[ 'min' ],
- ]);
+ if ($param[ 'min' ] > 0) {
+ $query->andWhere(
+ [
+ '>=',
+ ProductVariant::tableName() . '.price',
+ $param[ 'min' ],
+ ]
+ );
}
- if($param[ 'max' ] > 0) {
- $query->andWhere([
- '<=',
- ProductVariant::tableName() . '.price',
- $param[ 'max' ],
- ]);
+ if ($param[ 'max' ] > 0) {
+ $query->andWhere(
+ [
+ '<=',
+ ProductVariant::tableName() . '.price',
+ $param[ 'max' ],
+ ]
+ );
}
break;
default:
/**
* @todo Refactor this
*/
- $query->andWhere(Product::tableName() . '.id IN (
+ $query->andWhere(
+ Product::tableName() . '.id IN (
SELECT DISTINCT products
FROM (
SELECT id AS products
FROM product_option
INNER JOIN tax_option ON tax_option.tax_option_id = product_option.option_id
INNER JOIN tax_group ON tax_group.tax_group_id = tax_option.tax_group_id
- WHERE tax_group.alias LIKE \'' . $key . '\' AND tax_option.alias IN (\'' . implode('\',\'', $param) . '\') OR product_id IN (
+ WHERE tax_group.alias LIKE \'' . $key . '\' AND tax_option.alias IN (\'' . implode(
+ '\',\'',
+ $param
+ ) . '\') OR product_id IN (
(SELECT product_id AS products
FROM product_variant_option
- INNER JOIN product_variant ON product_variant_option.product_variant_id = product_variant.product_variant_id
+ INNER JOIN product_variant ON product_variant_option.product_variant_id = product_variant.id
INNER JOIN tax_option ON tax_option.tax_option_id = product_variant_option.option_id
INNER JOIN tax_group ON tax_group.tax_group_id = tax_option.tax_group_id
- WHERE tax_group.alias LIKE \'' . $key . '\' AND tax_option.alias IN (\'' . implode('\',\'', $param) . '\'))
+ WHERE tax_group.alias LIKE \'' . $key . '\' AND tax_option.alias IN (\'' . implode(
+ '\',\'',
+ $param
+ ) . '\'))
)
) AS table_name
- )');
+ )'
+ );
break;
}
@@ -285,16 +324,16 @@
*
* @return ActiveQuery
*/
- public static function productCountQuery($category = NULL, $params, $excludeKeys = [])
+ public static function productCountQuery($category = null, $params, $excludeKeys = [])
{
$p = [];
- foreach($params as $key => $param) {
- if(in_array($key, $excludeKeys)) {
+ foreach ($params as $key => $param) {
+ if (in_array($key, $excludeKeys)) {
$p[ $key ] = $param;
}
}
/** @var ActiveQuery $query */
- if(!empty( $category )) {
+ if (!empty( $category )) {
$query = $category->getProducts();
} else {
$query = Product::find();
diff --git a/common/modules/product/models/Category.php b/common/modules/product/models/Category.php
index 1197860..367b2b2 100755
--- a/common/modules/product/models/Category.php
+++ b/common/modules/product/models/Category.php
@@ -14,6 +14,7 @@
/**
* This is the model class for table "category".
+ *
* @todo Write doc for ArtboxTreeBehavior
* @property integer $category_id
* @property integer $remote_id
@@ -25,7 +26,7 @@
* @property Product[] $products
* @property ProductUnit $productUnit
* @property ProductCategory[] $productCategories
- * * From language behavior *
+ * * From language behavior *
* @property CategoryLang $lang
* @property CategoryLang[] $langs
* @property CategoryLang $objectLang
@@ -44,13 +45,13 @@
* @method bool linkLangs()
* @method bool saveLangs()
* @method bool getTransactionStatus()
- * * End language behavior *
- * * From SaveImgBehavior
+ * * End language behavior *
+ * * From SaveImgBehavior
* @property string|null $imageFile
* @property string|null $imageUrl
* @method string|null getImageFile( int $field )
* @method string|null getImageUrl( int $field )
- * * End SaveImgBehavior
+ * * End SaveImgBehavior
*/
class Category extends ActiveRecord
{
@@ -60,7 +61,7 @@
return [
'artboxtree' => [
'class' => ArtboxTreeBehavior::className(),
- 'keyNameGroup' => NULL,
+ 'keyNameGroup' => null,
'keyNamePath' => 'path',
],
'language' => [
@@ -115,7 +116,7 @@
public function attributeLabels()
{
return [
- 'id' => Yii::t('product', 'Category ID'),
+ 'id' => Yii::t('product', 'Category ID'),
'parent_id' => Yii::t('product', 'Parent ID'),
'path' => Yii::t('product', 'Path'),
'depth' => Yii::t('product', 'Depth'),
@@ -136,7 +137,7 @@
*/
public function getProductUnit()
{
- return $this->hasOne(ProductUnit::className(), [ 'product_unit_id' => 'product_unit_id' ]);
+ return $this->hasOne(ProductUnit::className(), [ 'id' => 'product_unit_id' ]);
}
public function getProducts()
@@ -171,9 +172,9 @@
public function beforeSave($insert)
{
- if(parent::beforeSave($insert)) {
+ if (parent::beforeSave($insert)) {
- if(empty( $this->parent_id )) {
+ if (empty( $this->parent_id )) {
$this->parent_id = 0;
}
@@ -185,53 +186,76 @@
public function getActiveFilters()
{
$query1 = ( new Query() )->distinct()
- ->select([
- 'option_id',
- ])
+ ->select(
+ [
+ 'option_id',
+ ]
+ )
->from('tax_option')
- ->innerJoin('product_variant_option', 'tax_option.tax_option_id = product_variant_option.option_id')
+ ->innerJoin(
+ 'product_variant_option',
+ 'tax_option.tax_option_id = product_variant_option.option_id'
+ )
->innerJoin('tax_group', 'tax_group.tax_group_id = tax_option.tax_group_id')
- ->innerJoin('product_variant', 'product_variant.product_variant_id = product_variant_option.product_variant_id')
+ ->innerJoin(
+ 'product_variant',
+ 'product_variant.id = product_variant_option.product_variant_id'
+ )
->innerJoin('product', 'product.id = product_variant.product_id')
->innerJoin('product_category', 'product_category.product_id = product.id')
- ->where([
- 'product_category.category_id' => $this->id,
- 'tax_group.is_filter' => true,
- ])
- ->andWhere([
- '!=',
- 'product_variant.stock',
- 0,
- ]);
+ ->where(
+ [
+ 'product_category.category_id' => $this->id,
+ 'tax_group.is_filter' => true,
+ ]
+ )
+ ->andWhere(
+ [
+ '!=',
+ 'product_variant.stock',
+ 0,
+ ]
+ );
$query2 = ( new Query() )->distinct()
- ->select([
- 'option_id',
- ])
+ ->select(
+ [
+ 'option_id',
+ ]
+ )
->from('tax_option')
- ->innerJoin('product_option', 'tax_option.tax_option_id = product_option.option_id')
+ ->innerJoin(
+ 'product_option',
+ 'tax_option.tax_option_id = product_option.option_id'
+ )
->innerJoin('tax_group', 'tax_group.tax_group_id = tax_option.tax_group_id')
->innerJoin('product', 'product.id = product_option.product_id')
->innerJoin('product_category', 'product_category.product_id = product.id')
->innerJoin('product_variant', 'product_variant.product_id = product.id')
- ->where([
- 'product_category.category_id' => $this->id,
- 'tax_group.is_filter' => true,
- ])
- ->andWhere([
- '!=',
- 'product_variant.stock',
- 0,
- ]);
- $query3 = ( new Query() )->select([
- 'tax_option.*',
- 'tax_group.*',
- 'tax_option.alias as option_alias',
- 'tax_group.alias as group_alias',
- 'tax_option.value as value',
- 'tax_option.sort AS tax_option_sort',
- 'tax_group.sort AS tax_group_sort',
- ])
+ ->where(
+ [
+ 'product_category.category_id' => $this->id,
+ 'tax_group.is_filter' => true,
+ ]
+ )
+ ->andWhere(
+ [
+ '!=',
+ 'product_variant.stock',
+ 0,
+ ]
+ );
+ $query3 = ( new Query() )->select(
+ [
+ 'tax_option.*',
+ 'tax_group.*',
+ 'tax_option.alias as option_alias',
+ 'tax_group.alias as group_alias',
+ 'tax_option.value as value',
+ 'tax_option.sort AS tax_option_sort',
+ 'tax_group.sort AS tax_group_sort',
+ ]
+ )
->from([ 'tax_option' ])
->where([ 'tax_option.tax_option_id' => $query1->union($query2) ])
->innerJoin('tax_group', 'tax_group.tax_group_id = tax_option.tax_group_id')
@@ -242,7 +266,8 @@
public function getTaxGroupsForMenu()
{
$connection = Yii::$app->getDb();
- $command = $connection->createCommand('
+ $command = $connection->createCommand(
+ '
SELECT ton.alias AS option_alias, *
FROM tax_option AS ton
RIGHT JOIN tax_group ON ton.tax_group_id = tax_group.tax_group_id
@@ -253,10 +278,12 @@
SELECT product_id FROM product_category WHERE category_id = :category_id
)
)
- AND tax_group.is_menu = TRUE AND tax_group_to_category.category_id = :category_id', [
- ':category_id' => $this->id,
-
- ]);
+ AND tax_group.is_menu = TRUE AND tax_group_to_category.category_id = :category_id',
+ [
+ ':category_id' => $this->id,
+
+ ]
+ );
return $command->queryAll();
}
diff --git a/common/modules/product/models/Export.php b/common/modules/product/models/Export.php
index 72fc9e8..e0a051c 100755
--- a/common/modules/product/models/Export.php
+++ b/common/modules/product/models/Export.php
@@ -32,11 +32,11 @@
];
}
- public function process($filename = NULL, $from = 0)
+ public function process($filename = null, $from = 0)
{
$limit = 100;
- if(empty( $filename )) {
+ if (empty( $filename )) {
$filename = 'products_' . date('d_m_Y_H_i') . '.csv';
$handle = fopen(\Yii::getAlias('@storage/sync/') . $filename, "w");
} else {
@@ -58,25 +58,29 @@
$filesize = Product::find()
->joinWith('lang', true, 'INNER JOIN')
->count();
- foreach($products as $product) {
+ foreach ($products as $product) {
$mods = [];
$filterString = $this->convertFilterToString($product->filters);
- foreach($product->variantsWithFilters as $variant) {
+ foreach ($product->variantsWithFilters as $variant) {
/**
* @var ProductVariant $variant
*/
$color = $variant->lang->title;
- $mods[] = $variant->sku . $this->generateID($variant->remote_id) . '=' . $this->convertFilterToString($variant->filters) . '=' . $color . '=' . ( ( !empty( $variant->image ) ) ? $variant->image->image : '' ) . '=' . $variant->stock;
+ $mods[] = $variant->sku . $this->generateID(
+ $variant->remote_id
+ ) . '=' . $this->convertFilterToString(
+ $variant->filters
+ ) . '=' . $color . '=' . ( ( !empty( $variant->image ) ) ? $variant->image->image : '' ) . '=' . $variant->stock;
}
$fotos = [];
- foreach($product->images as $image) {
+ foreach ($product->images as $image) {
$fotos[] = $image->image;
}
$categories = [];
- foreach($product->categories as $value) {
+ foreach ($product->categories as $value) {
$categories[] = $value->lang->title . $this->generateID($value->remote_id);
}
@@ -85,7 +89,9 @@
$list = [
$categories,
//A - категории через запятую Название(remote_id)
- ( ( !empty( $product->brand ) ) ? $product->brand->lang->title . $this->generateID($product->brand->remote_id) : '' ),
+ ( ( !empty( $product->brand ) ) ? $product->brand->lang->title . $this->generateID(
+ $product->brand->remote_id
+ ) : '' ),
//B - бренд Название(remote_id)
$product->lang->title . $this->generateID($product->remote_id),
//C - название товара Название(remote_id)
@@ -97,7 +103,7 @@
//F - страрая цена
( !empty( $product->variant ) ) ? $product->variant->price : '',
//G - новая цена
- intval($product->akciya),
+ intval($product->is_discount),
//H - товар акционный (1/0)
'',
//I - пустой
@@ -120,7 +126,7 @@
$from += $limit;
$end = false;
- if($from > $filesize) {
+ if ($from > $filesize) {
$end = true;
}
@@ -131,10 +137,13 @@
'filename' => $filename,
];
- if($end) {
- $result = array_merge($result, [
- 'link' => '/storage/sync/' . $filename,
- ]);
+ if ($end) {
+ $result = array_merge(
+ $result,
+ [
+ 'link' => '/storage/sync/' . $filename,
+ ]
+ );
}
return $result;
@@ -147,12 +156,14 @@
/**
* @var TaxOption[] $filters
*/
- foreach($filters as $filter) {
- $fittersArray[ $filter->taxGroup->lang->title . $this->generateID($filter->taxGroup->remote_id) ][] = $filter->lang->value . $this->generateID($filter->remote_id);
+ foreach ($filters as $filter) {
+ $fittersArray[ $filter->taxGroup->lang->title . $this->generateID(
+ $filter->taxGroup->remote_id
+ ) ][] = $filter->lang->value . $this->generateID($filter->remote_id);
}
$filterString = [];
- foreach($fittersArray as $filterName => $filterRows) {
+ foreach ($fittersArray as $filterName => $filterRows) {
$row = implode(',', $filterRows);
$filterString[] = "[{$filterName}:{$row}]";
}
diff --git a/common/modules/product/models/Import.php b/common/modules/product/models/Import.php
index d703f97..c951ea9 100755
--- a/common/modules/product/models/Import.php
+++ b/common/modules/product/models/Import.php
@@ -63,33 +63,42 @@
public function getType()
{
- if(!$this->type) {
+ if (!$this->type) {
$this->type = 'products';
}
return $this->type;
}
- public function goPrices($from = 0, $limit = NULL)
+ public function goPrices($from = 0, $limit = null)
{
set_time_limit(0);
- if(!( $handle = $this->getProductsFile('uploadFilePrices') )) {
+ if (!( $handle = $this->getProductsFile('uploadFilePrices') )) {
$this->errors[] = 'File not found';
return false;
}
$filesize = filesize(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFilePrices'));
- if($from) {
+ if ($from) {
fseek($handle, $from);
}
$j = 0;
- $is_utf = ( preg_match('//u', file_get_contents(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFilePrices'), NULL, NULL, NULL, 1000000)) );
+ $is_utf = ( preg_match(
+ '//u',
+ file_get_contents(
+ Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFilePrices'),
+ null,
+ null,
+ null,
+ 1000000
+ )
+ ) );
- while(( empty( $limit ) || $j++ < $limit ) && ( $data = fgetcsv($handle, 10000, ";") ) !== false) {
- foreach($data as &$value) {
- if(!$is_utf) {
+ while (( empty( $limit ) || $j++ < $limit ) && ( $data = fgetcsv($handle, 10000, ";") ) !== false) {
+ foreach ($data as &$value) {
+ if (!$is_utf) {
$value = iconv('windows-1251', "UTF-8//TRANSLIT//IGNORE", $value);
}
$value = trim($value);
@@ -103,29 +112,29 @@
$city_name = @$data[ 4 ];
$product_title = @$data[ 5 ];
- if(empty ( $modification_code )) {
+ if (empty ( $modification_code )) {
continue;
}
// товары в пути
- if(empty ( $city_name )) {
+ if (empty ( $city_name )) {
$this->output[] = 'Товар ' . $product_title . ' в пути';
continue;
}
/**
* @var ProductVariant $productVariant
*/
- if(( $productVariant = ProductVariant::find()
- ->filterWhere([ 'sku' => $modification_code ])
- ->one() ) === NULL
+ if (( $productVariant = ProductVariant::find()
+ ->filterWhere([ 'sku' => $modification_code ])
+ ->one() ) === null
) {
$this->output[] = 'Для товара ' . $product_title . ' не найдено соотвествие';
continue;
}
// ===== Set stock ====
- if($city_name) {
- if(( $stock = Stock::find()
- ->filterWhere([ 'title' => trim($city_name) ])
- ->one() ) === NULL
+ if ($city_name) {
+ if (( $stock = Stock::find()
+ ->filterWhere([ 'title' => trim($city_name) ])
+ ->one() ) === null
) {
// Create stock
$stock = new Stock();
@@ -134,37 +143,44 @@
}
$productStock = ProductStock::find()
- ->where([
- 'product_variant_id' => $productVariant->product_variant_id,
- 'stock_id' => $stock->stock_id,
- ])
+ ->where(
+ [
+ 'product_variant_id' => $productVariant->id,
+ 'stock_id' => $stock->id,
+ ]
+ )
->one();
- if(!$productStock instanceof ProductStock) {
- $productStock = new ProductStock;
- $productStock->product_variant_id = $productVariant->product_variant_id;
- $productStock->stock_id = $stock->stock_id;
- $productStock->product_id = $productVariant->product_id;
+ if (!$productStock instanceof ProductStock) {
+ $productStock = new ProductStock();
+ $productStock->product_variant_id = $productVariant->id;
+ $productStock->stock_id = $stock->id;
}
$productStock->quantity = $count;
$productStock->save(false);
$productStocks = ProductStock::find()
- ->where([ 'product_variant_id' => $productVariant->product_variant_id ])
- ->andWhere([
- '<>',
- 'stock_id',
- $stock->stock_id,
- ])
+ ->where(
+ [ 'product_variant_id' => $productVariant->id ]
+ )
+ ->andWhere(
+ [
+ '<>',
+ 'stock_id',
+ $stock->id,
+ ]
+ )
->all();
$quantity = array_sum(ArrayHelper::getColumn($productStocks, 'quantity')) + $count;
} else {
$productStocks = ProductStock::find()
- ->where([ 'product_variant_id' => $productVariant->product_variant_id ])
+ ->where(
+ [ 'product_variant_id' => $productVariant->id ]
+ )
->all();
- if($productStocks instanceof ProductStock) {
+ if ($productStocks instanceof ProductStock) {
$quantity = array_sum(ArrayHelper::getColumn($productStocks, 'quantity')) + $count;
} else {
$quantity = 0;
@@ -172,7 +188,7 @@
}
- if($price_promo) {
+ if ($price_promo) {
$productVariant->price_old = $price;
$productVariant->price = $price_promo;
} else {
@@ -197,7 +213,7 @@
fclose($handle);
- if($result[ 'end' ]) {
+ if ($result[ 'end' ]) {
unlink(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFilePrices'));
}
@@ -214,8 +230,8 @@
$pattern = '/^(?P.*)(?:\(#(?P\w+)#\))?$/U';
$name = trim($name);
$matches = [];
- if(preg_match($pattern, $name, $matches)) {
- if(!isset( $matches[ 'remote_id' ] )) {
+ if (preg_match($pattern, $name, $matches)) {
+ if (!isset( $matches[ 'remote_id' ] )) {
$matches[ 'remote_id' ] = '';
}
return $matches;
@@ -236,19 +252,24 @@
{
$category_id = [];
- foreach($catalog_names as $catalog_name) {
+ foreach ($catalog_names as $catalog_name) {
// ==== Set category ====
$parsed_name = $this->parseName($catalog_name);
- if(!empty( $parsed_name[ 'remote_id' ] ) && ( $category = Category::find()
- ->joinWith('lang')
- ->andFilterWhere([ 'remote_id' => $parsed_name[ 'remote_id' ] ])
- ->one() ) !== NULL
+ if (!empty( $parsed_name[ 'remote_id' ] ) && ( $category = Category::find()
+ ->joinWith('lang')
+ ->andFilterWhere(
+ [ 'remote_id' => $parsed_name[ 'remote_id' ] ]
+ )
+ ->one() ) !== null
) {
- if(!empty( $category->lang )) {
+ if (!empty( $category->lang )) {
$category->lang->title = $parsed_name[ 'name' ];
$category->lang->save(false);
} else {
- throw new \Exception('Category with ID ' . $category->id . ' and lang ' . Language::getCurrent()->id . ' doesn\'t exist');
+ throw new \Exception(
+ 'Category with ID ' . $category->id . ' and lang ' . Language::getCurrent(
+ )->id . ' doesn\'t exist'
+ );
}
} else {
@@ -256,7 +277,7 @@
$category = new Category();
$category->generateLangs();
$category_langs = $category->modelLangs;
- foreach($category_langs as $category_lang) {
+ foreach ($category_langs as $category_lang) {
$category_lang->title = $parsed_name[ 'name' ];
}
$category->remote_id = $parsed_name[ 'remote_id' ];
@@ -273,24 +294,29 @@
* @return int|null
* @throws \Exception
*/
- private function saveBrand(string $brand_name = NULL):int
+ private function saveBrand(string $brand_name = null):int
{
$parsed_name = $this->parseName($brand_name);
- if(!empty( $brand_name )) {
+ if (!empty( $brand_name )) {
/**
* @var Brand $brand
*/
- if(!empty( $parsed_name[ 'remote_id' ] ) && ( $brand = Brand::find()
- ->joinWith('lang')
- ->andFilterWhere([ 'remote_id' => $parsed_name[ 'remote_id' ] ])
- ->one() ) !== NULL
+ if (!empty( $parsed_name[ 'remote_id' ] ) && ( $brand = Brand::find()
+ ->joinWith('lang')
+ ->andFilterWhere(
+ [ 'remote_id' => $parsed_name[ 'remote_id' ] ]
+ )
+ ->one() ) !== null
) {
- if(!empty( $brand->lang )) {
+ if (!empty( $brand->lang )) {
$brand->lang->title = $parsed_name[ 'name' ];
$brand->lang->save(false);
} else {
- throw new \Exception('Brand with ID ' . $brand->id . ' and lang ' . Language::getCurrent()->id . ' doesn\'t exist');
+ throw new \Exception(
+ 'Brand with ID ' . $brand->id . ' and lang ' . Language::getCurrent(
+ )->id . ' doesn\'t exist'
+ );
}
return $brand->id;
} else {
@@ -298,7 +324,7 @@
$brand = new Brand();
$brand->generateLangs();
$brand_langs = $brand->modelLangs;
- foreach($brand_langs as $brand_lang) {
+ foreach ($brand_langs as $brand_lang) {
$brand_lang->title = $parsed_name[ 'name' ];
}
$brand->remote_id = $parsed_name[ 'remote_id' ];
@@ -306,7 +332,7 @@
return $brand->id;
}
}
- return NULL;
+ return null;
}
/**
@@ -314,21 +340,23 @@
* @param int $product_id
* @param int $product_variant_id
*/
- private function saveFotos(array $fotos, int $product_id, int $product_variant_id = NULL)
+ private function saveFotos(array $fotos, int $product_id, int $product_variant_id = null)
{
- if(!empty( $fotos )) {
- foreach($fotos as $foto) {
+ if (!empty( $fotos )) {
+ foreach ($fotos as $foto) {
- if(empty( $foto )) {
+ if (empty( $foto )) {
continue;
}
$source_image = Yii::getAlias('@uploadDir') . '/product_images/' . urlencode($foto);
- if(file_exists($source_image)) {
- if(( $productImage = ProductImage::find()
- ->andWhere([ 'image' => $foto ])
- ->andWhere([ 'product_id' => $product_id ])
- ->andFilterWhere([ 'product_variant_id' => $product_variant_id ])
- ->one() ) === NULL
+ if (file_exists($source_image)) {
+ if (( $productImage = ProductImage::find()
+ ->andWhere([ 'image' => $foto ])
+ ->andWhere([ 'product_id' => $product_id ])
+ ->andFilterWhere(
+ [ 'product_variant_id' => $product_variant_id ]
+ )
+ ->one() ) === null
) {
copy($source_image, Yii::getAlias('@productsDir') . "/" . $foto);
$productImage = new ProductImage();
@@ -352,17 +380,23 @@
* @return array
* @throws \Exception
*/
- private function saveVariants(array $data, float $product_cost_old, int $product_id, array $category_id, float $product_cost = NULL):array
+ private function saveVariants(
+ array $data,
+ float $product_cost_old,
+ int $product_id,
+ array $category_id,
+ float $product_cost = null
+ ):array
{
$MOD_ARRAY = [];
- for($i = 13; $i < count($data); $i++) {
- if(!empty ( $data[ $i ] )) {
+ for ($i = 13; $i < count($data); $i++) {
+ if (!empty ( $data[ $i ] )) {
$mod_arr = explode('=', $data[ $i ]);
$mod_art = $mod_arr[ 0 ];
$mod_art_parsed = $this->parseName($mod_art);
$variant_filters = explode('*', $mod_arr[ 1 ]);
$mod_name = $mod_arr[ 2 ];
- if(empty( $mod_name )) {
+ if (empty( $mod_name )) {
$mod_name = $mod_art_parsed[ 'name' ];
}
$mod_image = $mod_arr[ 3 ];
@@ -373,28 +407,35 @@
/**
* @var ProductVariant $_productVariant
*/
- if(( $_productVariant = ProductVariant::find()
- ->joinWith('lang')
- ->andFilterWhere([ 'remote_id' => $mod_art_parsed[ 'remote_id' ] ])
- ->andFilterWhere([ 'product_variant.product_id' => $product_id ])
- ->one() ) === NULL
+ if (( $_productVariant = ProductVariant::find()
+ ->joinWith('lang')
+ ->andFilterWhere(
+ [ 'remote_id' => $mod_art_parsed[ 'remote_id' ] ]
+ )
+ ->andFilterWhere(
+ [ 'product_variant.product_id' => $product_id ]
+ )
+ ->one() ) === null
) {
$_productVariant = new ProductVariant();
$_productVariant->product_id = $product_id;
- if(!empty( $mod_art_parsed[ 'remote_id' ] )) {
+ if (!empty( $mod_art_parsed[ 'remote_id' ] )) {
$_productVariant->remote_id = $mod_art_parsed[ 'remote_id' ];
}
$_productVariant->generateLangs();
$product_variant_langs = $_productVariant->modelLangs;
- foreach($product_variant_langs as $product_variant_lang) {
+ foreach ($product_variant_langs as $product_variant_lang) {
$product_variant_lang->title = $mod_name;
}
} else {
- if(!empty( $_productVariant->lang )) {
+ if (!empty( $_productVariant->lang )) {
$_productVariant->lang->title = $mod_name;
$_productVariant->lang->save(false);
} else {
- throw new \Exception('Product variant with ID ' . $_productVariant->product_variant_id . ' and lang ' . Language::getCurrent()->id . ' doesn\'t exist');
+ throw new \Exception(
+ 'Product variant with ID ' . $_productVariant->id . ' and lang ' . Language::getCurrent(
+ )->id . ' doesn\'t exist'
+ );
}
}
$_productVariant->product_unit_id = 1;
@@ -403,11 +444,11 @@
$_productVariant->price_old = $mod_old_cost;
$_productVariant->stock = $mod_stock;
- if(!empty ( $variant_filters )) {
+ if (!empty ( $variant_filters )) {
$variants_options = $this->saveFilters($variant_filters, 1, $category_id);
}
- if(isset( $variants_options ) && !empty( $variants_options )) {
+ if (isset( $variants_options ) && !empty( $variants_options )) {
$_productVariant->options = $variants_options;
}
@@ -416,8 +457,8 @@
*/
$_productVariant->save(false);
- $MOD_ARRAY[] = $_productVariant->product_variant_id;
- $this->saveFotos([ $mod_image ], $product_id, $_productVariant->product_variant_id);
+ $MOD_ARRAY[] = $_productVariant->id;
+ $this->saveFotos([ $mod_image ], $product_id, $_productVariant->id);
}
}
return $MOD_ARRAY;
@@ -427,45 +468,54 @@
// echo $message.': '.(time()-$start_time).'s passed';
// }
- public function goProducts($from = 0, $limit = NULL)
+ public function goProducts($from = 0, $limit = null)
{
set_time_limit(0);
- if(!( $handle = $this->getProductsFile('uploadFileProducts') )) {
+ if (!( $handle = $this->getProductsFile('uploadFileProducts') )) {
$this->errors[] = 'File not found';
return false;
}
$filesize = filesize(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFileProducts'));
- if($from) {
+ if ($from) {
fseek($handle, $from);
}
$j = 0;
- $is_utf = ( preg_match('//u', file_get_contents(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFileProducts'), NULL, NULL, NULL, 1000000)) );
+ $is_utf = ( preg_match(
+ '//u',
+ file_get_contents(
+ Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFileProducts'),
+ null,
+ null,
+ null,
+ 1000000
+ )
+ ) );
$result_items = [];
- while(( empty( $limit ) || $j++ < $limit ) && ( $data = fgetcsv($handle, 10000, ";") ) !== false) {
+ while (( empty( $limit ) || $j++ < $limit ) && ( $data = fgetcsv($handle, 10000, ";") ) !== false) {
try {
- foreach($data as &$value) {
- if(!$is_utf) {
+ foreach ($data as &$value) {
+ if (!$is_utf) {
$value = iconv('windows-1251', "UTF-8//TRANSLIT//IGNORE", $value);
}
$value = trim($value);
}
// будет всегда 19 элементов
- for($i = 0; $i <= 18; $i++) {
- if(!isset ( $data[ $i ] )) {
- $data[ $i ] = NULL;
+ for ($i = 0; $i <= 18; $i++) {
+ if (!isset ( $data[ $i ] )) {
+ $data[ $i ] = null;
}
}
// 1 Группа (категория)
$catalog_names = explode(',', $data[ 0 ]);
- if(empty ( $catalog_names )) {
+ if (empty ( $catalog_names )) {
$result_items[] = "Не указана категория (строка $j)";
continue;
}
@@ -479,7 +529,7 @@
// 3 Название товара
$product_name = $data[ 2 ];
- if(empty ( $product_name )) {
+ if (empty ( $product_name )) {
$result_items[] = "Не указано наименование товара (строка $j)";
continue;
}
@@ -493,15 +543,15 @@
// 11 Цена акция
$product_cost_old = floatval($data[ 6 ]);
- $product_cost = NULL;
+ $product_cost = null;
// 10 Цена
- if($product_cost_old) {
+ if ($product_cost_old) {
$product_cost_old = floatval($data[ 5 ]);
$product_cost = floatval($data[ 6 ]);
}
// 12 Акция
- $product_akciya = (bool) $data[ 7 ];
+ $product_discount = (bool) $data[ 7 ];
// 13 Сопуд. Тов.
$similar = explode(',', $data[ 8 ]);
@@ -517,7 +567,7 @@
// 18 Галлерея фото
$fotos = [];
- if(trim($data[ 12 ])) {
+ if (trim($data[ 12 ])) {
$fotos = explode(',', trim($data[ 12 ]));
}
@@ -534,30 +584,35 @@
$brand_id = $this->saveBrand($brand_name);
$options = [];
- if(!empty ( $filters )) {
+ if (!empty ( $filters )) {
$options = $this->saveFilters($filters, 0, $categories);
}
$parsed_name = $this->parseName($product_name);
/**
* @var Product $_product
*/
- if(!empty( $parsed_name[ 'remote_id' ] ) && ( $_product = Product::find()
- ->joinWith('lang')
- ->andFilterWhere([ 'remote_id' => $parsed_name[ 'remote_id' ] ])
- ->one() ) !== NULL
+ if (!empty( $parsed_name[ 'remote_id' ] ) && ( $_product = Product::find()
+ ->joinWith('lang')
+ ->andFilterWhere(
+ [ 'remote_id' => $parsed_name[ 'remote_id' ] ]
+ )
+ ->one() ) !== null
) {
- if(!empty( $_product->lang )) {
+ if (!empty( $_product->lang )) {
$_product->lang->title = $parsed_name[ 'name' ];
$_product->lang->description = $product_body;
$_product->lang->save(false);
} else {
- throw new \Exception('Product with ID ' . $_product->id . ' and lang ' . Language::getCurrent()->id . ' doesn\'t exist');
+ throw new \Exception(
+ 'Product with ID ' . $_product->id . ' and lang ' . Language::getCurrent(
+ )->id . ' doesn\'t exist'
+ );
}
} else {
$_product = new Product();
$_product->generateLangs();
$product_langs = $_product->modelLangs;
- foreach($product_langs as $product_lang) {
+ foreach ($product_langs as $product_lang) {
$product_lang->title = $parsed_name[ 'name' ];
$product_lang->description = $product_body;
}
@@ -571,19 +626,19 @@
$_product->video = $product_video;
$_product->is_top = $product_top;
- $_product->akciya = $product_akciya;
+ $_product->is_discount = $product_discount;
$_product->is_new = $product_new;
- if(!empty( $options )) {
+ if (!empty( $options )) {
$_product->options = $options;
}
- if(!empty( $_product->lang )) {
+ if (!empty( $_product->lang )) {
$product_name_inserted = $_product->lang->title;
} else {
$product_name_inserted = $_product->modelLangs[ Language::$current->id ]->title;
}
- if(( $_product->save(false) === false ) || !$_product->transactionStatus) {
+ if (( $_product->save(false) === false ) || !$_product->transactionStatus) {
$result_items[] = 'Product #' . $product_name_inserted . ' not saved' . " (line $j)";
continue;
}
@@ -597,7 +652,7 @@
$result_items[] = "Product {$product_name_inserted} #{$_product->id} saved (" . ( $is_new_product ? 'new product' : 'exists product' ) . ")" . " (line $j)";
- } catch(\Exception $e) {
+ } catch (\Exception $e) {
$result_items[] = $e->getMessage() . '(line ' . $j . ')';
}
@@ -612,7 +667,7 @@
fclose($handle);
- if($result[ 'end' ]) {
+ if ($result[ 'end' ]) {
// unlink(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFileProducts'));
}
@@ -622,7 +677,7 @@
private function getProductsFile($file_type)
{
$filename = Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@' . $file_type);
- if(!is_file($filename)) {
+ if (!is_file($filename)) {
$this->errors[] = "File $filename not found";
return false;
}
@@ -642,11 +697,11 @@
private function saveFilters(array $filters, int $level, array $catalog_names):array
{
$options = [];
- foreach($filters as $filter) {
+ foreach ($filters as $filter) {
preg_match_all('/\[(.*):(.*)\]/', $filter, $filter);
- if(empty( $filter[ 1 ][ 0 ] )) {
+ if (empty( $filter[ 1 ][ 0 ] )) {
continue;
}
$filter_name = trim($filter[ 1 ][ 0 ]);
@@ -655,22 +710,27 @@
/**
* @var TaxGroup $taxGroup
*/
- if(!empty( $parsed_group_name[ 'remote_id' ] ) && ( $taxGroup = TaxGroup::find()
- ->joinWith('lang')
- ->andFilterWhere([ 'remote_id' => $parsed_group_name[ 'remote_id' ] ])
- ->one() ) !== NULL
+ if (!empty( $parsed_group_name[ 'remote_id' ] ) && ( $taxGroup = TaxGroup::find()
+ ->joinWith('lang')
+ ->andFilterWhere(
+ [ 'remote_id' => $parsed_group_name[ 'remote_id' ] ]
+ )
+ ->one() ) !== null
) {
- if(!empty( $taxGroup->lang )) {
+ if (!empty( $taxGroup->lang )) {
$taxGroup->lang->title = $parsed_group_name[ 'name' ];
$taxGroup->lang->save(false);
} else {
- throw new \Exception('Tax group with ID ' . $taxGroup->tax_group_id . ' and lang ' . Language::getCurrent()->id . ' doesn\'t exist');
+ throw new \Exception(
+ 'Tax group with ID ' . $taxGroup->tax_group_id . ' and lang ' . Language::getCurrent(
+ )->id . ' doesn\'t exist'
+ );
}
} else {
$taxGroup = new TaxGroup();
$taxGroup->generateLangs();
$tax_group_langs = $taxGroup->modelLangs;
- foreach($tax_group_langs as $tax_group_lang) {
+ foreach ($tax_group_langs as $tax_group_lang) {
$tax_group_lang->title = $parsed_group_name[ 'name' ];
}
$taxGroup->level = $level;
@@ -679,30 +739,37 @@
$taxGroup->save(false);
}
$filters_options = explode(',', $filter[ 2 ][ 0 ]);
- foreach($filters_options as $filter_options) {
+ foreach ($filters_options as $filter_options) {
$parsed_option_name = $this->parseName($filter_options);
/**
* @var TaxOption $option
*/
- if(!empty( $parsed_option_name[ 'remote_id' ] ) && ( $option = TaxOption::find()
- ->joinWith('lang')
- ->andFilterWhere([ 'remote_id' => $parsed_option_name[ 'remote_id' ] ])
- ->andFilterWhere([ 'tax_group_id' => $taxGroup->tax_group_id ])
- ->one() ) !== NULL
+ if (!empty( $parsed_option_name[ 'remote_id' ] ) && ( $option = TaxOption::find()
+ ->joinWith('lang')
+ ->andFilterWhere(
+ [ 'remote_id' => $parsed_option_name[ 'remote_id' ] ]
+ )
+ ->andFilterWhere(
+ [ 'tax_group_id' => $taxGroup->tax_group_id ]
+ )
+ ->one() ) !== null
) {
- if(!empty( $option->lang )) {
+ if (!empty( $option->lang )) {
$option->lang->value = $parsed_option_name[ 'name' ];
$option->lang->save(false);
} else {
- throw new \Exception('Tax option with ID ' . $option->tax_option_id . ' and lang ' . Language::getCurrent()->id . ' doesn\'t exist');
+ throw new \Exception(
+ 'Tax option with ID ' . $option->tax_option_id . ' and lang ' . Language::getCurrent(
+ )->id . ' doesn\'t exist'
+ );
}
} else {
// Create option
$option = new TaxOption();
$option->generateLangs();
$option_langs = $option->modelLangs;
- foreach($option_langs as $option_lang) {
+ foreach ($option_langs as $option_lang) {
$option_lang->value = $parsed_option_name[ 'name' ];
}
$option->tax_group_id = $taxGroup->tax_group_id;
diff --git a/common/modules/product/models/Product.php b/common/modules/product/models/Product.php
index 3a67a40..8c69031 100755
--- a/common/modules/product/models/Product.php
+++ b/common/modules/product/models/Product.php
@@ -18,6 +18,7 @@
/**
* This is the model class for table "{{%product}}".
+ *
* @property integer $brand_id
* @property integer $id
* @property Category $category
@@ -26,7 +27,7 @@
* @property ProductVariant $variant
* @property boolean $is_top
* @property boolean $is_new
- * @property boolean $akciya
+ * @property boolean $is_discount
* @property ProductToRating $averageRating
* @property array $properties
* @property ProductVariant $enabledVariant
@@ -98,7 +99,7 @@
'id' => 'product_id',
],
'conditions' => [
- 'product_variant_id' => NULL,
+ 'product_variant_id' => null,
],
'model' => ProductImage::className(),
'config' => [
@@ -153,7 +154,7 @@
[
'is_top',
'is_new',
- 'akciya',
+ 'is_discount',
],
'boolean',
],
@@ -166,19 +167,19 @@
public function attributeLabels()
{
return [
- 'id' => Yii::t('product', 'ID'),
- 'brand_id' => Yii::t('product', 'Brand'),
- 'categories' => Yii::t('product', 'Categories'),
+ 'id' => Yii::t('product', 'ID'),
+ 'brand_id' => Yii::t('product', 'Brand'),
+ 'categories' => Yii::t('product', 'Categories'),
// relation behavior field
- 'category' => Yii::t('product', 'Category'),
+ 'category' => Yii::t('product', 'Category'),
// relation behavior field
- 'image' => Yii::t('product', 'Image'),
- 'images' => Yii::t('product', 'Images'),
- 'video' => Yii::t('product', 'Video embeded'),
- 'variants' => Yii::t('product', 'Variants'),
- 'is_top' => Yii::t('product', 'Is top'),
- 'is_new' => Yii::t('product', 'Is new'),
- 'akciya' => Yii::t('product', 'Is promo'),
+ 'image' => Yii::t('product', 'Image'),
+ 'images' => Yii::t('product', 'Images'),
+ 'video' => Yii::t('product', 'Video embeded'),
+ 'variants' => Yii::t('product', 'Variants'),
+ 'is_top' => Yii::t('product', 'Is top'),
+ 'is_new' => Yii::t('product', 'Is new'),
+ 'is_discount' => Yii::t('product', 'Is promo'),
];
}
@@ -204,11 +205,13 @@
public function getEnabledVariant()
{
return $this->hasOne(ProductVariant::className(), [ 'product_id' => 'id' ])
- ->andOnCondition([
- '!=',
- ProductVariant::tableName() . '.stock',
- 0,
- ]);
+ ->andOnCondition(
+ [
+ '!=',
+ ProductVariant::tableName() . '.stock',
+ 0,
+ ]
+ );
}
public function getVariantPrice()
@@ -232,11 +235,13 @@
public function getEnabledVariants()
{
return $this->hasMany(ProductVariant::className(), [ 'product_id' => 'id' ])
- ->andOnCondition([
- '!=',
- ProductVariant::tableName() . '.stock',
- 0,
- ])
+ ->andOnCondition(
+ [
+ '!=',
+ ProductVariant::tableName() . '.stock',
+ 0,
+ ]
+ )
->joinWith('image');
}
@@ -262,7 +267,7 @@
public function getCategoriesNames()
{
$result = [];
- foreach($this->categories as $category) {
+ foreach ($this->categories as $category) {
$result[] = $category->lang->title;
}
return $result;
@@ -272,10 +277,12 @@
{
return $this->hasMany(ProductVariant::className(), [ 'product_id' => 'id' ])
->joinWith('lang', true, 'INNER JOIN')
- ->with([
- 'filters',
- 'image',
- ]);
+ ->with(
+ [
+ 'filters',
+ 'image',
+ ]
+ );
}
/**
@@ -299,16 +306,16 @@
public function getProperties()
{
$groups = $options = [];
- foreach($this->getOptions()
- ->with('lang')
- ->all() as $option) {
+ foreach ($this->getOptions()
+ ->with('lang')
+ ->all() as $option) {
$options[ $option->tax_group_id ][] = $option;
}
- foreach(TaxGroup::find()
- ->where([ 'tax_group_id' => array_keys($options) ])
- ->with('lang')
- ->all() as $group) {
- if(!empty( $options[ $group->tax_group_id ] )) {
+ foreach (TaxGroup::find()
+ ->where([ 'tax_group_id' => array_keys($options) ])
+ ->with('lang')
+ ->all() as $group) {
+ if (!empty( $options[ $group->tax_group_id ] )) {
$group->options = $options[ $group->tax_group_id ];
$groups[] = $group;
}
@@ -319,21 +326,23 @@
public function getActiveProperties($category_id)
{
$groups = $options = [];
- foreach($this->options as $option) {
+ foreach ($this->options as $option) {
$options[ $option->tax_group_id ][] = $option;
}
$taxGroups = TaxGroup::find()
->joinWith('categories')
- ->where([
- 'tax_group.tax_group_id' => array_keys($options),
- 'tax_group.display' => true,
- 'category.id' => $category_id,
- ])
+ ->where(
+ [
+ 'tax_group.tax_group_id' => array_keys($options),
+ 'tax_group.display' => true,
+ 'category.id' => $category_id,
+ ]
+ )
->all();
- foreach($taxGroups as $group) {
- if(!empty( $options[ $group->tax_group_id ] )) {
+ foreach ($taxGroups as $group) {
+ if (!empty( $options[ $group->tax_group_id ] )) {
$group->options = $options[ $group->tax_group_id ];
$groups[] = $group;
}
@@ -343,8 +352,8 @@
public function getStocks()
{
- return $this->hasMany(Stock::className(), [ 'stock_id' => 'stock_id' ])
- ->viaTable(ProductStock::tableName(), [ 'product_id' => 'id' ]);
+ return $this->hasMany(Stock::className(), [ 'id' => 'product_id' ])
+ ->via('variants');
}
public function getQuantity()
@@ -358,34 +367,37 @@
{
parent::afterSave($insert, $changedAttributes);
- if(!empty( $this->categories )) {
+ if (!empty( $this->categories )) {
$categories = Category::findAll($this->categories);
$this->unlinkAll('categories', true);
- foreach($categories as $category) {
+ foreach ($categories as $category) {
$this->link('categories', $category);
}
}
- if(!empty( $this->options )) {
+ if (!empty( $this->options )) {
$options = TaxOption::findAll($this->options);
$this->unlinkAll('options', true);
- foreach($options as $option) {
+ foreach ($options as $option) {
$this->link('options', $option);
}
}
- if(!empty( $this->variants )) {
+ if (!empty( $this->variants )) {
$todel = [];
- foreach($this->variants ? : [] as $_variant) {
- $todel[ $_variant->product_variant_id ] = $_variant->product_variant_id;
+ foreach ($this->variants ? : [] as $_variant) {
+ /**
+ * @var ProductVariant $_variant
+ */
+ $todel[ $_variant->id ] = $_variant->id;
}
- foreach($this->variants as $_variant) {
- if(!is_array($_variant)) {
+ foreach ($this->variants as $_variant) {
+ if (!is_array($_variant)) {
return;
}
- if(!empty( $_variant[ 'product_variant_id' ] )) {
- unset( $todel[ $_variant[ 'product_variant_id' ] ] );
- $model = ProductVariant::findOne($_variant[ 'product_variant_id' ]);
+ if (!empty( $_variant[ 'id' ] )) {
+ unset( $todel[ $_variant[ 'id' ] ] );
+ $model = ProductVariant::findOne($_variant[ 'id' ]);
} else {
$model = new ProductVariant();
}
@@ -394,8 +406,8 @@
$model->product_id = $this->id;
$model->save();
}
- if(!empty( $todel )) {
- ProductVariant::deleteAll([ 'product_variant_id' => $todel ]);
+ if (!empty( $todel )) {
+ ProductVariant::deleteAll([ 'id' => $todel ]);
}
}
}
@@ -409,19 +421,21 @@
->joinWith('rating')
->select([ 'average' => 'avg(artbox_comment_rating.value)::float' ])
->scalar();
- if(!$average) {
+ if (!$average) {
$average = 0;
}
$averageRating = $this->averageRating;
- if(!empty( $averageRating )) {
+ if (!empty( $averageRating )) {
$averageRating->value = $average;
} else {
- $averageRating = new ProductToRating([
- 'product_id' => $this->id,
- 'value' => $average,
- ]);
+ $averageRating = new ProductToRating(
+ [
+ 'product_id' => $this->id,
+ 'value' => $average,
+ ]
+ );
}
- if($averageRating->save()) {
+ if ($averageRating->save()) {
return true;
} else {
return false;
@@ -431,11 +445,13 @@
public function getComments()
{
return $this->hasMany(CommentModel::className(), [ 'entity_id' => 'id' ])
- ->where([
- 'artbox_comment.entity' => self::className(),
- 'artbox_comment.status' => CommentModel::STATUS_ACTIVE,
- 'artbox_comment.artbox_comment_pid' => NULL,
- ]);
+ ->where(
+ [
+ 'artbox_comment.entity' => self::className(),
+ 'artbox_comment.status' => CommentModel::STATUS_ACTIVE,
+ 'artbox_comment.artbox_comment_pid' => null,
+ ]
+ );
}
public function getAverageRating()
@@ -448,7 +464,10 @@
$categories = ArrayHelper::getColumn($this->categories, 'id');
return TaxGroup::find()
->distinct()
- ->innerJoin('tax_group_to_category', 'tax_group_to_category.tax_group_id = tax_group.tax_group_id')
+ ->innerJoin(
+ 'tax_group_to_category',
+ 'tax_group_to_category.tax_group_id = tax_group.tax_group_id'
+ )
->andWhere([ 'tax_group_to_category.category_id' => $categories ])
->andWhere([ 'level' => $level ]);
}
diff --git a/common/modules/product/models/ProductImage.php b/common/modules/product/models/ProductImage.php
index 827a6cb..b0c66b3 100755
--- a/common/modules/product/models/ProductImage.php
+++ b/common/modules/product/models/ProductImage.php
@@ -8,6 +8,7 @@
/**
* This is the model class for table "product_image".
+ *
* @property integer $product_image_id
* @property integer $product_id
* @property integer $product_variant_id
@@ -78,7 +79,7 @@
'exist',
'skipOnError' => true,
'targetClass' => ProductVariant::className(),
- 'targetAttribute' => [ 'product_variant_id' => 'product_variant_id' ],
+ 'targetAttribute' => [ 'product_variant_id' => 'id' ],
],
];
}
@@ -106,7 +107,7 @@
public function getProduct()
{
$return = $this->hasOne(Product::className(), [ 'id' => 'product_id' ]);
- if(empty( $return )) {
+ if (empty( $return )) {
$return = $this->productVariant->product_id;
}
return $return;
@@ -117,6 +118,6 @@
*/
public function getProductVariant()
{
- return $this->hasOne(Product::className(), [ 'product_variant_id' => 'product_variant_id' ]);
+ return $this->hasOne(ProductVariant::className(), [ 'id' => 'product_variant_id' ]);
}
}
diff --git a/common/modules/product/models/ProductSearch.php b/common/modules/product/models/ProductSearch.php
index cbf2e89..db5353b 100755
--- a/common/modules/product/models/ProductSearch.php
+++ b/common/modules/product/models/ProductSearch.php
@@ -22,7 +22,7 @@
public function behaviors()
{
$behaviors = parent::behaviors();
- if(isset( $behaviors[ 'language' ] )) {
+ if (isset( $behaviors[ 'language' ] )) {
unset( $behaviors[ 'language' ] );
}
return $behaviors;
@@ -52,7 +52,7 @@
[
'is_top',
'is_new',
- 'akciya',
+ 'is_discount',
],
'boolean',
],
@@ -64,7 +64,7 @@
$labels = parent::attributeLabels();
$new_labels = [
'categoryId' => 'Category ID',
- 'brand_id' => 'Brand ID',
+ 'brand_id' => 'Brand ID',
'productName' => 'Product name',
'variantCount' => 'Variant count',
];
@@ -91,79 +91,101 @@
{
$query = Product::find();
- $query->select([
- 'product.*',
- 'COUNT(product_variant.product_variant_id) as count',
- ]);
+ $query->select(
+ [
+ 'product.*',
+ 'COUNT(product_variant.id) as count',
+ ]
+ );
- $query->joinWith([
- 'categories',
- 'lang',
- ])
- ->joinWith([
- 'brand' => function($query) {
- /**
- * @var ActiveQuery $query
- */
- $query->joinWith('lang');
- },
- ])
+ $query->joinWith(
+ [
+ 'categories',
+ 'lang',
+ ]
+ )
+ ->joinWith(
+ [
+ 'brand' => function ($query) {
+ /**
+ * @var ActiveQuery $query
+ */
+ $query->joinWith('lang');
+ },
+ ]
+ )
->joinWith('variants');
- $query->groupBy([
- 'product.id',
- 'brand_lang.title',
- 'product_lang.title',
- ]);
+ $query->groupBy(
+ [
+ 'product.id',
+ 'brand_lang.title',
+ 'product_lang.title',
+ ]
+ );
- $dataProvider = new ActiveDataProvider([
- 'query' => $query,
- ]);
+ $dataProvider = new ActiveDataProvider(
+ [
+ 'query' => $query,
+ ]
+ );
- $dataProvider->setSort([
- 'attributes' => [
- 'id',
- 'productName' => [
- 'asc' => [ 'product_lang.title' => SORT_ASC ],
- 'desc' => [ 'product_lang.title' => SORT_DESC ],
- ],
- 'brand_id' => [
- 'asc' => [ 'brand_lang.title' => SORT_ASC ],
- 'desc' => [ 'brand_lang.title' => SORT_DESC ],
- 'default' => SORT_DESC,
- ],
- 'variantCount' => [
- 'asc' => [ 'count' => SORT_ASC ],
- 'desc' => [ 'count' => SORT_DESC ],
+ $dataProvider->setSort(
+ [
+ 'attributes' => [
+ 'id',
+ 'productName' => [
+ 'asc' => [ 'product_lang.title' => SORT_ASC ],
+ 'desc' => [ 'product_lang.title' => SORT_DESC ],
+ ],
+ 'brand_id' => [
+ 'asc' => [ 'brand_lang.title' => SORT_ASC ],
+ 'desc' => [ 'brand_lang.title' => SORT_DESC ],
+ 'default' => SORT_DESC,
+ ],
+ 'variantCount' => [
+ 'asc' => [ 'count' => SORT_ASC ],
+ 'desc' => [ 'count' => SORT_DESC ],
+ ],
],
- ],
- ]);
+ ]
+ );
- if(isset( $this->is_top )) {
- $query->andWhere([
- 'is_top' => (bool) $this->is_top,
- ]);
+ if (isset( $this->is_top )) {
+ $query->andWhere(
+ [
+ 'is_top' => (bool) $this->is_top,
+ ]
+ );
}
- if(isset( $this->is_new )) {
- $query->andWhere([
- 'is_new' => (bool) $this->is_new,
- ]);
+ if (isset( $this->is_new )) {
+ $query->andWhere(
+ [
+ 'is_new' => (bool) $this->is_new,
+ ]
+ );
}
- if(isset( $this->akciya )) {
- $query->andWhere([
- 'akciya' => (bool) $this->akciya,
- ]);
+ if (isset( $this->is_discount )) {
+ $query->andWhere(
+ [
+ 'is_discount' => (bool) $this->is_discount,
+ ]
+ );
}
- $query->andFilterWhere([
- 'product.brand_id' => $this->brand_id,
- 'product.id' => $this->id,
- 'product_category.category_id' => $this->categoryId,
- ]);
- $query->andFilterWhere([
- 'like',
- 'product_lang.title',
- $this->productName,
- ]);
+ $query->andFilterWhere(
+ [
+ 'product.brand_id' => $this->brand_id,
+ 'product.id' => $this->id,
+ 'product_category.category_id' => $this->categoryId,
+ ]
+ );
+ $query->andFilterWhere(
+ [
+ 'like',
+ 'product_lang.title',
+ $this->productName,
+ ]
+ );
return $dataProvider;
}
diff --git a/common/modules/product/models/ProductStock.php b/common/modules/product/models/ProductStock.php
index 31bb09c..50f8a45 100755
--- a/common/modules/product/models/ProductStock.php
+++ b/common/modules/product/models/ProductStock.php
@@ -6,7 +6,7 @@
/**
* This is the model class for table "product_stock".
- * @property integer $product_id
+ *
* @property integer $stock_id
* @property integer $quantity
* @property integer $product_variant_id
@@ -33,7 +33,6 @@
return [
[
[
- 'product_id',
'stock_id',
'quantity',
'product_variant_id',
@@ -45,25 +44,18 @@
'required',
],
[
- [ 'product_id' ],
- 'exist',
- 'skipOnError' => true,
- 'targetClass' => Product::className(),
- 'targetAttribute' => [ 'product_id' => 'id' ],
- ],
- [
[ 'product_variant_id' ],
'exist',
'skipOnError' => true,
'targetClass' => ProductVariant::className(),
- 'targetAttribute' => [ 'product_variant_id' => 'product_variant_id' ],
+ 'targetAttribute' => [ 'product_variant_id' => 'id' ],
],
[
[ 'stock_id' ],
'exist',
'skipOnError' => true,
'targetClass' => Stock::className(),
- 'targetAttribute' => [ 'stock_id' => 'stock_id' ],
+ 'targetAttribute' => [ 'stock_id' => 'id' ],
],
];
}
@@ -74,11 +66,10 @@
public function attributeLabels()
{
return [
- 'product_id' => 'Product ID',
'stock_id' => 'Stock ID',
'quantity' => 'Количество',
'product_variant_id' => 'Product Variant ID',
- 'title' => "Название",
+ 'title' => "Название",
];
}
@@ -87,7 +78,8 @@
*/
public function getProduct()
{
- return $this->hasOne(Product::className(), [ 'id' => 'product_id' ]);
+ return $this->hasOne(Product::className(), [ 'id' => 'product_id' ])
+ ->via('variants');
}
/**
@@ -95,14 +87,14 @@
*/
public function getProductVariant()
{
- return $this->hasOne(ProductVariant::className(), [ 'product_variant_id' => 'product_variant_id' ]);
+ return $this->hasOne(ProductVariant::className(), [ 'id' => 'product_variant_id' ]);
}
public function getName()
{
return ( !empty( $this->stock ) ) ? $this->stock->title : '';
}
-
+
/**
* @todo Check if needed
*
@@ -118,7 +110,7 @@
*/
public function getStock()
{
- return $this->hasOne(Stock::className(), [ 'stock_id' => 'stock_id' ]);
+ return $this->hasOne(Stock::className(), [ 'id' => 'stock_id' ]);
}
public static function primaryKey()
diff --git a/common/modules/product/models/ProductUnit.php b/common/modules/product/models/ProductUnit.php
index 3b24fb0..4a9ca31 100755
--- a/common/modules/product/models/ProductUnit.php
+++ b/common/modules/product/models/ProductUnit.php
@@ -10,7 +10,8 @@
/**
* This is the model class for table "product_unit".
- * @property integer $product_unit_id
+ *
+ * @property integer $id
* @property boolean $is_default
* @property Category[] $categories
* @property ProductVariant[] $productVariants
@@ -74,8 +75,8 @@
public function attributeLabels()
{
return [
- 'product_unit_id' => Yii::t('product', 'Product Unit ID'),
- 'is_default' => Yii::t('product', 'Is Default'),
+ 'id' => Yii::t('product', 'Product Unit ID'),
+ 'is_default' => Yii::t('product', 'Is Default'),
];
}
@@ -84,7 +85,7 @@
*/
public function getCategories()
{
- return $this->hasMany(Category::className(), [ 'product_unit_id' => 'product_unit_id' ]);
+ return $this->hasMany(Category::className(), [ 'product_unit_id' => 'id' ]);
}
/**
@@ -92,6 +93,6 @@
*/
public function getProductVariants()
{
- return $this->hasMany(ProductVariant::className(), [ 'product_unit_id' => 'product_unit_id' ]);
+ return $this->hasMany(ProductVariant::className(), [ 'product_unit_id' => 'id' ]);
}
}
diff --git a/common/modules/product/models/ProductUnitLang.php b/common/modules/product/models/ProductUnitLang.php
index c181348..4249b4d 100755
--- a/common/modules/product/models/ProductUnitLang.php
+++ b/common/modules/product/models/ProductUnitLang.php
@@ -8,6 +8,7 @@
/**
* This is the model class for table "product_unit_lang".
+ *
* @property integer $product_unit_id
* @property integer $language_id
* @property string $title
@@ -76,7 +77,7 @@
'exist',
'skipOnError' => true,
'targetClass' => ProductUnit::className(),
- 'targetAttribute' => [ 'product_unit_id' => 'product_unit_id' ],
+ 'targetAttribute' => [ 'product_unit_id' => 'id' ],
],
];
}
@@ -89,7 +90,7 @@
return [
'product_unit_id' => Yii::t('app', 'Product Unit ID'),
'language_id' => Yii::t('app', 'Language ID'),
- 'title' => Yii::t('app', 'Name'),
+ 'title' => Yii::t('app', 'Name'),
'short' => Yii::t('app', 'Short'),
];
}
@@ -107,6 +108,6 @@
*/
public function getProductUnit()
{
- return $this->hasOne(ProductUnit::className(), [ 'product_unit_id' => 'product_unit_id' ]);
+ return $this->hasOne(ProductUnit::className(), [ 'id' => 'product_unit_id' ]);
}
}
diff --git a/common/modules/product/models/ProductUnitSearch.php b/common/modules/product/models/ProductUnitSearch.php
index ffcdfb5..1a0e981 100755
--- a/common/modules/product/models/ProductUnitSearch.php
+++ b/common/modules/product/models/ProductUnitSearch.php
@@ -39,7 +39,7 @@
'safe',
],
[
- [ 'product_unit_id' ],
+ [ 'id' ],
'integer',
],
[
@@ -72,38 +72,44 @@
// add conditions that should always apply here
- $dataProvider = new ActiveDataProvider([
- 'query' => $query,
- 'sort' => [
- 'attributes' => [
- 'product_unit_id',
- 'is_defaut',
- 'title' => [
- 'asc' => [ 'product_unit_lang.title' => SORT_ASC ],
- 'desc' => [ 'product_unit_lang.title' => SORT_DESC ],
+ $dataProvider = new ActiveDataProvider(
+ [
+ 'query' => $query,
+ 'sort' => [
+ 'attributes' => [
+ 'id',
+ 'is_defaut',
+ 'title' => [
+ 'asc' => [ 'product_unit_lang.title' => SORT_ASC ],
+ 'desc' => [ 'product_unit_lang.title' => SORT_DESC ],
+ ],
],
],
- ],
- ]);
+ ]
+ );
$this->load($params);
- if(!$this->validate()) {
+ 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;
}
// grid filtering conditions
- $query->andFilterWhere([
- 'product_unit_id' => $this->product_unit_id,
- 'is_default' => $this->is_default,
- ])
- ->andFilterWhere([
- 'ilike',
- 'product_unit_lang.title',
- $this->title,
- ]);
+ $query->andFilterWhere(
+ [
+ 'id' => $this->id,
+ 'is_default' => $this->is_default,
+ ]
+ )
+ ->andFilterWhere(
+ [
+ 'ilike',
+ 'product_unit_lang.title',
+ $this->title,
+ ]
+ );
return $dataProvider;
}
diff --git a/common/modules/product/models/ProductVariant.php b/common/modules/product/models/ProductVariant.php
index 685dd67..7b0330e 100755
--- a/common/modules/product/models/ProductVariant.php
+++ b/common/modules/product/models/ProductVariant.php
@@ -17,7 +17,7 @@
* This is the model class for table "product_variant".
*
* @todo Refactor
- * @property integer $product_variant_id
+ * @property integer $id
* @property integer $product_id
* @property integer $remote_id
* @property string $sku
@@ -96,15 +96,15 @@
'directory' => 'products',
'column' => 'image',
'links' => [
- 'product_id' => 'product_id',
- 'product_variant_id' => 'product_variant_id',
+ 'product_id' => 'product_id',
+ 'id' => 'product_variant_id',
],
'model' => ProductImage::className(),
],
'multipleImage' => [
'class' => MultipleImgBehavior::className(),
'links' => [
- 'product_variant_id' => 'product_variant_id',
+ 'id' => 'product_variant_id',
],
'model' => ProductImage::className(),
'config' => [
@@ -162,7 +162,7 @@
'exist',
'skipOnError' => true,
'targetClass' => ProductUnit::className(),
- 'targetAttribute' => [ 'product_unit_id' => 'product_unit_id' ],
+ 'targetAttribute' => [ 'product_unit_id' => 'id' ],
],
];
}
@@ -173,16 +173,16 @@
public function attributeLabels()
{
return [
- 'product_variant_id' => Yii::t('product', 'Product Variant ID'),
- 'product_id' => Yii::t('product', 'Product ID'),
- 'sku' => Yii::t('product', 'Sku'),
- 'price' => Yii::t('product', 'Price'),
- 'price_old' => Yii::t('product', 'Price Old'),
- 'stock' => Yii::t('product', 'Stock'),
- 'product_unit_id' => Yii::t('product', 'Product Unit ID'),
- 'stock_caption' => Yii::t('product', 'Stock'),
- 'image' => Yii::t('product', 'Image'),
- 'images' => Yii::t('product', 'Images'),
+ 'id' => Yii::t('product', 'Product Variant ID'),
+ 'product_id' => Yii::t('product', 'Product ID'),
+ 'sku' => Yii::t('product', 'Sku'),
+ 'price' => Yii::t('product', 'Price'),
+ 'price_old' => Yii::t('product', 'Price Old'),
+ 'stock' => Yii::t('product', 'Stock'),
+ 'product_unit_id' => Yii::t('product', 'Product Unit ID'),
+ 'stock_caption' => Yii::t('product', 'Stock'),
+ 'image' => Yii::t('product', 'Image'),
+ 'images' => Yii::t('product', 'Images'),
];
}
@@ -191,7 +191,7 @@
*/
public function getProductUnit()
{
- return $this->hasOne(ProductUnit::className(), [ 'product_unit_id' => 'product_unit_id' ]);
+ return $this->hasOne(ProductUnit::className(), [ 'id' => 'product_unit_id' ]);
}
/**
@@ -204,13 +204,13 @@
public function getProductStock()
{
- return $this->hasMany(ProductStock::className(), [ 'product_variant_id' => 'product_variant_id' ]);
+ return $this->hasMany(ProductStock::className(), [ 'product_variant_id' => 'id' ]);
}
public function getQuantity()
{
return ProductStock::find()
- ->where([ 'product_variant_id' => $this->product_variant_id ])
+ ->where([ 'product_variant_id' => $this->id ])
->sum('quantity');
}
@@ -224,20 +224,20 @@
public function getVariantStocks()
{
- return $this->hasMany(ProductStock::className(), [ 'product_variant_id' => 'product_variant_id' ])
+ return $this->hasMany(ProductStock::className(), [ 'product_variant_id' => 'id' ])
->joinWith('stock');
}
public function getStocks()
{
- return $this->hasMany(Stock::className(), [ 'stock_id' => 'stock_id' ])
- ->viaTable(ProductStock::tableName(), [ 'product_variant_id' => 'product_variant_id' ]);
+ return $this->hasMany(Stock::className(), [ 'id' => 'stock_id' ])
+ ->viaTable(ProductStock::tableName(), [ 'product_variant_id' => 'id' ]);
}
public function getFilters()
{
return $this->hasMany(TaxOption::className(), [ 'tax_option_id' => 'option_id' ])
- ->viaTable('product_variant_option', [ 'product_variant_id' => 'product_variant_id' ])
+ ->viaTable('product_variant_option', [ 'product_variant_id' => 'id' ])
->joinWith('taxGroup.lang', true, 'INNER JOIN')
->joinWith('lang', true, 'INNER JOIN');
}
@@ -255,7 +255,7 @@
public function getOptions()
{
return $this->hasMany(TaxOption::className(), [ 'tax_option_id' => 'option_id' ])
- ->viaTable('product_variant_option', [ 'product_variant_id' => 'product_variant_id' ]);
+ ->viaTable('product_variant_option', [ 'product_variant_id' => 'id' ]);
}
/**
@@ -282,11 +282,6 @@
return $groups;
}
- public function getId()
- {
- return $this->product_variant_id;
- }
-
/**
* @todo Check if needed
*
@@ -334,7 +329,7 @@
}
if (!empty( $this->stocks )) {
- ProductStock::deleteAll([ 'product_variant_id' => $this->product_variant_id ]);
+ ProductStock::deleteAll([ 'product_variant_id' => $this->id ]);
foreach ($this->stocks as $id => $quantity) {
/**
* @var ProductStock $productStock
@@ -342,7 +337,7 @@
$productStock = ProductStock::find()
->where(
[
- 'product_variant_id' => $this->product_variant_id,
+ 'product_variant_id' => $this->id,
'stock_id' => $id,
]
)
diff --git a/common/modules/product/models/ProductVariantLang.php b/common/modules/product/models/ProductVariantLang.php
index 57368c2..8c2bb4a 100755
--- a/common/modules/product/models/ProductVariantLang.php
+++ b/common/modules/product/models/ProductVariantLang.php
@@ -8,6 +8,7 @@
/**
* This is the model class for table "product_variant_lang".
+ *
* @property integer $product_variant_id
* @property integer $language_id
* @property string $title
@@ -72,7 +73,7 @@
'exist',
'skipOnError' => true,
'targetClass' => ProductVariant::className(),
- 'targetAttribute' => [ 'product_variant_id' => 'product_variant_id' ],
+ 'targetAttribute' => [ 'product_variant_id' => 'id' ],
],
];
}
@@ -85,7 +86,7 @@
return [
'product_variant_id' => Yii::t('app', 'Product Variant ID'),
'language_id' => Yii::t('app', 'Language ID'),
- 'title' => Yii::t('app', 'Name'),
+ 'title' => Yii::t('app', 'Name'),
];
}
@@ -102,6 +103,6 @@
*/
public function getProductVariant()
{
- return $this->hasOne(ProductVariant::className(), [ 'product_variant_id' => 'product_variant_id' ]);
+ return $this->hasOne(ProductVariant::className(), [ 'id' => 'product_variant_id' ]);
}
}
diff --git a/common/modules/product/models/ProductVariantOption.php b/common/modules/product/models/ProductVariantOption.php
index a100ae8..740b55c 100755
--- a/common/modules/product/models/ProductVariantOption.php
+++ b/common/modules/product/models/ProductVariantOption.php
@@ -7,6 +7,7 @@
/**
* This is the model class for table "product_variant_option".
+ *
* @property integer $product_variant_id
* @property integer $option_id
* @property ProductVariant $productVariant
@@ -48,7 +49,7 @@
'exist',
'skipOnError' => true,
'targetClass' => ProductVariant::className(),
- 'targetAttribute' => [ 'product_variant_id' => 'product_variant_id' ],
+ 'targetAttribute' => [ 'product_variant_id' => 'id' ],
],
[
[ 'option_id' ],
@@ -76,7 +77,7 @@
*/
public function getProductVariant()
{
- return $this->hasOne(ProductVariant::className(), [ 'product_variant_id' => 'product_variant_id' ]);
+ return $this->hasOne(ProductVariant::className(), [ 'id' => 'product_variant_id' ]);
}
/**
diff --git a/common/modules/product/models/ProductVariantSearch.php b/common/modules/product/models/ProductVariantSearch.php
index 62beff8..6522ddf 100755
--- a/common/modules/product/models/ProductVariantSearch.php
+++ b/common/modules/product/models/ProductVariantSearch.php
@@ -34,7 +34,7 @@
],
[
[
- 'product_variant_id',
+ 'id',
'stock',
],
'integer',
@@ -72,53 +72,65 @@
// add conditions that should always apply here
- $dataProvider = new ActiveDataProvider([
- 'query' => $query,
- ]);
+ $dataProvider = new ActiveDataProvider(
+ [
+ 'query' => $query,
+ ]
+ );
$this->load($params);
- if(!$this->validate()) {
+ 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;
}
- $dataProvider->setSort([
- 'attributes' => [
- 'product_variant_id',
- 'sku',
- 'variantName' => [
- 'asc' => [ 'product_variant_lang.title' => SORT_ASC ],
- 'desc' => [ 'product_variant_lang.title' => SORT_DESC ],
+ $dataProvider->setSort(
+ [
+ 'attributes' => [
+ 'id',
+ 'sku',
+ 'variantName' => [
+ 'asc' => [ 'product_variant_lang.title' => SORT_ASC ],
+ 'desc' => [ 'product_variant_lang.title' => SORT_DESC ],
+ ],
+ 'price',
+ 'price_old',
+ 'stock',
],
- 'price',
- 'price_old',
- 'stock',
- ],
- ]);
+ ]
+ );
- $query->andFilterWhere([
- 'price' => $this->price,
- 'price_old' => $this->price_old,
- 'stock' => $this->stock,
- ]);
+ $query->andFilterWhere(
+ [
+ 'price' => $this->price,
+ 'price_old' => $this->price_old,
+ 'stock' => $this->stock,
+ ]
+ );
- $query->andFilterWhere([
- 'ilike',
- 'product_variant_lang.title',
- $this->variantName,
- ])
- ->andFilterWhere([
- 'ilike',
- 'sku',
- $this->sku,
- ]);
+ $query->andFilterWhere(
+ [
+ 'ilike',
+ 'product_variant_lang.title',
+ $this->variantName,
+ ]
+ )
+ ->andFilterWhere(
+ [
+ 'ilike',
+ 'sku',
+ $this->sku,
+ ]
+ );
- $query->groupBy([
- 'product_variant.product_variant_id',
- 'product_variant_lang.title',
- ]);
+ $query->groupBy(
+ [
+ 'product_variant.id',
+ 'product_variant_lang.title',
+ ]
+ );
return $dataProvider;
}
diff --git a/common/modules/product/models/Stock.php b/common/modules/product/models/Stock.php
index 66063a3..e96649b 100755
--- a/common/modules/product/models/Stock.php
+++ b/common/modules/product/models/Stock.php
@@ -7,8 +7,9 @@
/**
* This is the model class for table "stock".
- * @property integer $stock_id
- * @property string $title
+ *
+ * @property integer $id
+ * @property string $title
* @property ProductStock[] $productStocks
*/
class Stock extends ActiveRecord
@@ -46,8 +47,25 @@
public function attributeLabels()
{
return [
- 'stock_id' => Yii::t('product', 'Stock ID'),
- 'title' => Yii::t('product', 'Name'),
+ 'id' => Yii::t('product', 'Stock ID'),
+ 'title' => Yii::t('product', 'Name'),
];
}
+
+ public function getProductStocks()
+ {
+ return $this->hasMany(ProductStock::className(), [ 'stock_id' => 'id' ]);
+ }
+
+ public function getProductVariants()
+ {
+ return $this->hasMany(ProductVariant::className(), [ 'id' => 'product_variant_id' ])
+ ->via('productStocks');
+ }
+
+ public function getProducts()
+ {
+ return $this->hasMany(Product::className(), [ 'id' => 'product_id' ])
+ ->via('productVariants');
+ }
}
diff --git a/common/modules/product/views/manage/_form.php b/common/modules/product/views/manage/_form.php
index 3642b85..56156fe 100755
--- a/common/modules/product/views/manage/_form.php
+++ b/common/modules/product/views/manage/_form.php
@@ -22,76 +22,98 @@
- [ 'enctype' => 'multipart/form-data' ],
- ]); ?>
+ [ 'enctype' => 'multipart/form-data' ],
+ ]
+ ); ?>
= $form->field($model, 'is_top')
->checkbox([ 'label' => 'ТОП' ]) ?>
= $form->field($model, 'is_new')
->checkbox([ 'label' => 'Новинка' ]) ?>
- = $form->field($model, 'akciya')
+ = $form->field($model, 'is_discount')
->checkbox([ 'label' => 'Акционный' ]) ?>
= $form->field($model, 'video')
->textarea(); ?>
= $form->field($model, 'brand_id')
- ->dropDownList(ArrayHelper::map(ProductHelper::getBrands()
- ->with('lang')
- ->all(), 'id', 'lang.title'), [
- 'prompt' => Yii::t('product', 'Select brand'),
- ]) ?>
+ ->dropDownList(
+ ArrayHelper::map(
+ ProductHelper::getBrands()
+ ->with('lang')
+ ->all(),
+ 'id',
+ 'lang.title'
+ ),
+ [
+ 'prompt' => Yii::t('product', 'Select brand'),
+ ]
+ ) ?>
= $form->field($model, 'categories')
- ->widget(Select2::className(), [
- 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'id', 'lang.title'),
- 'language' => 'ru',
- 'options' => [
- 'placeholder' => Yii::t('product', 'Select categories'),
- 'multiple' => true,
- ],
- 'pluginOptions' => [
- 'allowClear' => true,
- ],
- ]) ?>
+ ->widget(
+ Select2::className(),
+ [
+ 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'id', 'lang.title'),
+ 'language' => 'ru',
+ 'options' => [
+ 'placeholder' => Yii::t('product', 'Select categories'),
+ 'multiple' => true,
+ ],
+ 'pluginOptions' => [
+ 'allowClear' => true,
+ ],
+ ]
+ ) ?>
= $form->field($model, 'imagesUpload[]')
- ->widget(\kartik\file\FileInput::className(), [
- 'language' => 'ru',
- 'options' => [
- 'accept' => 'image/*',
- 'multiple' => true,
- ],
- 'pluginOptions' => [
- 'allowedFileExtensions' => [
- 'jpg',
- 'gif',
- 'png',
+ ->widget(
+ \kartik\file\FileInput::className(),
+ [
+ 'language' => 'ru',
+ 'options' => [
+ 'accept' => 'image/*',
+ 'multiple' => true,
+ ],
+ 'pluginOptions' => [
+ 'allowedFileExtensions' => [
+ 'jpg',
+ 'gif',
+ 'png',
+ ],
+ 'initialPreview' => !empty( $model->imagesHTML ) ? $model->imagesHTML : [],
+ 'initialPreviewConfig' => $model->imagesConfig,
+ 'overwriteInitial' => false,
+ 'showRemove' => false,
+ 'showUpload' => false,
+ 'uploadAsync' => !empty( $model->id ),
+ 'previewFileType' => 'image',
],
- 'initialPreview' => !empty( $model->imagesHTML ) ? $model->imagesHTML : [],
- 'initialPreviewConfig' => $model->imagesConfig,
- 'overwriteInitial' => false,
- 'showRemove' => false,
- 'showUpload' => false,
- 'uploadAsync' => !empty( $model->id ),
- 'previewFileType' => 'image',
- ],
- ]); ?>
+ ]
+ ); ?>
- with('lang')
- ->all() as $group) {
+ with('lang')
+ ->all() as $group) {
/**
* @var TaxGroup $group
*/
echo $form->field($model, 'options')
- ->checkboxList(ArrayHelper::map($group->getOptions()
- ->with('lang')
- ->all(), 'tax_option_id', 'lang.value'), [
- 'multiple' => true,
- 'unselect' => NULL,
- ])
+ ->checkboxList(
+ ArrayHelper::map(
+ $group->getOptions()
+ ->with('lang')
+ ->all(),
+ 'tax_option_id',
+ 'lang.value'
+ ),
+ [
+ 'multiple' => true,
+ 'unselect' => null,
+ ]
+ )
->label($group->lang->title);
}
}
@@ -99,14 +121,19 @@
- = LanguageForm::widget([
- 'modelLangs' => $modelLangs,
- 'formView' => '@common/modules/product/views/manage/_form_language',
- 'form' => $form,
- ]) ?>
+ = LanguageForm::widget(
+ [
+ 'modelLangs' => $modelLangs,
+ 'formView' => '@common/modules/product/views/manage/_form_language',
+ 'form' => $form,
+ ]
+ ) ?>
- = Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
+ = Html::submitButton(
+ $model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'),
+ [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
+ ) ?>
diff --git a/common/modules/product/views/manage/index.php b/common/modules/product/views/manage/index.php
index a544045..f8b8699 100755
--- a/common/modules/product/views/manage/index.php
+++ b/common/modules/product/views/manage/index.php
@@ -116,9 +116,9 @@
],
[
'class' => 'yii\grid\ActionColumn',
- 'template' => '{items} {view} |{is_top} {is_new} {akciya} | {update} {delete}',
+ 'template' => '{items} {view} |{is_top} {is_new} {is_discount} | {update} {delete}',
'buttons' => [
- 'is_top' => function ($url, $model) {
+ 'is_top' => function ($url, $model) {
return Html::a(
'
',
$url,
@@ -127,7 +127,7 @@
]
);
},
- 'is_new' => function ($url, $model) {
+ 'is_new' => function ($url, $model) {
return Html::a(
'
',
$url,
@@ -136,19 +136,19 @@
]
);
},
- 'akciya' => function ($url, $model) {
+ 'is_discount' => function ($url, $model) {
return Html::a(
- '
',
+ '
',
$url,
[
'title' => Yii::t(
'product',
- ( $model->akciya ? 'Set not is promotion' : 'Set is promotion' )
+ ( $model->is_discount ? 'Set not is promotion' : 'Set is promotion' )
),
]
);
},
- 'items' => function ($url, $model) {
+ 'items' => function ($url, $model) {
return Html::a(
'
',
$url,
@@ -188,10 +188,10 @@
]
);
break;
- case 'akciya':
+ case 'is_discount':
return \yii\helpers\Url::to(
[
- 'manage/akciya',
+ 'manage/is-discount',
'id' => $model->id,
]
);
diff --git a/common/modules/product/views/manage/view.php b/common/modules/product/views/manage/view.php
index e99cfe6..b636ada 100755
--- a/common/modules/product/views/manage/view.php
+++ b/common/modules/product/views/manage/view.php
@@ -37,7 +37,7 @@
$variant->lang->title,
[
'/product/variant/view',
- 'id' => $variant->product_variant_id,
+ 'id' => $variant->id,
]
) . '
';
}
@@ -109,8 +109,8 @@
'format' => 'html',
],
[
- 'attribute' => 'akciya',
- 'value' => $model->akciya ? Html::tag(
+ 'attribute' => 'is_discount',
+ 'value' => $model->is_discount ? Html::tag(
'span',
'',
[ 'class' => 'glyphicon glyphicon-ok' ]
diff --git a/common/modules/product/views/product-unit/index.php b/common/modules/product/views/product-unit/index.php
index 2ffa3e7..0e0ef4d 100755
--- a/common/modules/product/views/product-unit/index.php
+++ b/common/modules/product/views/product-unit/index.php
@@ -22,25 +22,27 @@
= Html::a(Yii::t('product', 'Create Product Unit'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
- = GridView::widget([
- 'dataProvider' => $dataProvider,
- 'filterModel' => $searchModel,
- 'columns' => [
- 'product_unit_id',
- [
- 'attribute' => 'is_default',
- 'format' => 'boolean',
- 'filter' => [
- \Yii::$app->formatter->asBoolean(false),
- \Yii::$app->formatter->asBoolean(true),
+ = GridView::widget(
+ [
+ 'dataProvider' => $dataProvider,
+ 'filterModel' => $searchModel,
+ 'columns' => [
+ 'id',
+ [
+ 'attribute' => 'is_default',
+ 'format' => 'boolean',
+ 'filter' => [
+ \Yii::$app->formatter->asBoolean(false),
+ \Yii::$app->formatter->asBoolean(true),
+ ],
],
+ [
+ 'attribute' => 'title',
+ 'value' => 'lang.title',
+ ],
+ 'lang.short',
+ [ 'class' => 'yii\grid\ActionColumn' ],
],
- [
- 'attribute' => 'title',
- 'value' => 'lang.title',
- ],
- 'lang.short',
- [ 'class' => 'yii\grid\ActionColumn' ],
- ],
- ]); ?>
+ ]
+ ); ?>
diff --git a/common/modules/product/views/product-unit/update.php b/common/modules/product/views/product-unit/update.php
index d299575..b5fd6a3 100755
--- a/common/modules/product/views/product-unit/update.php
+++ b/common/modules/product/views/product-unit/update.php
@@ -22,7 +22,7 @@
'label' => $model->lang->title,
'url' => [
'view',
- 'id' => $model->product_unit_id,
+ 'id' => $model->id,
],
];
$this->params[ 'breadcrumbs' ][] = Yii::t('product', 'Update');
diff --git a/common/modules/product/views/product-unit/view.php b/common/modules/product/views/product-unit/view.php
index 732ae11..5eeab53 100755
--- a/common/modules/product/views/product-unit/view.php
+++ b/common/modules/product/views/product-unit/view.php
@@ -22,30 +22,40 @@
= Html::encode($this->title) ?>
- = Html::a(Yii::t('product', 'Update'), [
- 'update',
- 'id' => $model->product_unit_id,
- ], [ 'class' => 'btn btn-primary' ]) ?>
- = Html::a(Yii::t('product', 'Delete'), [
- 'delete',
- 'id' => $model->product_unit_id,
- ], [
- 'class' => 'btn btn-danger',
- 'data' => [
- 'confirm' => Yii::t('product', 'Are you sure you want to delete this item?'),
- 'method' => 'post',
+ = Html::a(
+ Yii::t('product', 'Update'),
+ [
+ 'update',
+ 'id' => $model->id,
],
- ]) ?>
+ [ 'class' => 'btn btn-primary' ]
+ ) ?>
+ = Html::a(
+ Yii::t('product', 'Delete'),
+ [
+ 'delete',
+ 'id' => $model->id,
+ ],
+ [
+ 'class' => 'btn btn-danger',
+ 'data' => [
+ 'confirm' => Yii::t('product', 'Are you sure you want to delete this item?'),
+ 'method' => 'post',
+ ],
+ ]
+ ) ?>
- = DetailView::widget([
- 'model' => $model,
- 'attributes' => [
- 'product_unit_id',
- 'is_default:boolean',
- 'lang.title',
- 'lang.short',
- ],
- ]) ?>
+ = DetailView::widget(
+ [
+ 'model' => $model,
+ 'attributes' => [
+ 'id',
+ 'is_default:boolean',
+ 'lang.title',
+ 'lang.short',
+ ],
+ ]
+ ) ?>
diff --git a/common/modules/product/views/variant/_form.php b/common/modules/product/views/variant/_form.php
index 94d8cb5..d8078de 100755
--- a/common/modules/product/views/variant/_form.php
+++ b/common/modules/product/views/variant/_form.php
@@ -78,7 +78,7 @@ $(".dynamicform_wrapper").on("limitReached", function(e, item) {
'overwriteInitial' => false,
'showRemove' => false,
'showUpload' => false,
- 'uploadAsync' => !empty( $model->product_variant_id ),
+ 'uploadAsync' => !empty( $model->id ),
'previewFileType' => 'image',
],
]
diff --git a/common/modules/product/views/variant/index.php b/common/modules/product/views/variant/index.php
index 727cd59..f32c110 100755
--- a/common/modules/product/views/variant/index.php
+++ b/common/modules/product/views/variant/index.php
@@ -50,7 +50,7 @@
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
- 'product_variant_id',
+ 'id',
[
'attribute' => 'variantName',
'value' => 'lang.title',
@@ -70,7 +70,7 @@
[
'view',
'product_id' => $model->product_id,
- 'id' => $model->product_variant_id,
+ 'id' => $model->id,
]
),
[
@@ -85,7 +85,7 @@
[
'update',
'product_id' => $model->product_id,
- 'id' => $model->product_variant_id,
+ 'id' => $model->id,
]
),
[
@@ -101,7 +101,7 @@
[
'delete',
'product_id' => $model->product_id,
- 'id' => $model->product_variant_id,
+ 'id' => $model->id,
]
),
[
diff --git a/common/modules/product/views/variant/update.php b/common/modules/product/views/variant/update.php
index b4d8000..7d96988 100755
--- a/common/modules/product/views/variant/update.php
+++ b/common/modules/product/views/variant/update.php
@@ -49,7 +49,7 @@
'url' => Url::to(
[
'view',
- 'id' => $model->product_variant_id,
+ 'id' => $model->id,
]
),
];
diff --git a/common/modules/product/views/variant/view.php b/common/modules/product/views/variant/view.php
index aa05ea8..0ac8a30 100755
--- a/common/modules/product/views/variant/view.php
+++ b/common/modules/product/views/variant/view.php
@@ -47,7 +47,7 @@
Yii::t('product', 'Update'),
[
'update',
- 'id' => $model->product_variant_id,
+ 'id' => $model->id,
],
[ 'class' => 'btn btn-primary' ]
) ?>
@@ -55,7 +55,7 @@
Yii::t('product', 'Delete'),
[
'delete',
- 'id' => $model->product_variant_id,
+ 'id' => $model->id,
],
[
'class' => 'btn btn-danger',
@@ -71,7 +71,7 @@
[
'model' => $model,
'attributes' => [
- 'product_variant_id',
+ 'id',
'lang.title',
'sku',
'price',
diff --git a/common/modules/product/widgets/views/product_smart.php b/common/modules/product/widgets/views/product_smart.php
index d7987cb..81ff5e9 100755
--- a/common/modules/product/widgets/views/product_smart.php
+++ b/common/modules/product/widgets/views/product_smart.php
@@ -11,24 +11,36 @@
- = Html::a($product->lang->title, Url::to([
- 'catalog/product',
- 'product' => $product->lang->alias,
- ]), [ 'class' => 'btn-product-details' ]) ?>
+ = Html::a(
+ $product->lang->title,
+ Url::to(
+ [
+ 'catalog/product',
+ 'product' => $product->lang->alias,
+ ]
+ ),
+ [ 'class' => 'btn-product-details' ]
+ ) ?>
-
- = \common\components\artboximage\ArtboxImageHelper::getImage($product->enabledVariants[ 0 ]->imageUrl, 'list', [
- 'alt' => $product->category->lang->title . ' ' . $product->fullname,
- 'title' => $product->category->lang->title . ' ' . $product->fullname,
- 'class' => 'selected',
- ]) ?>
+
+ = \common\components\artboximage\ArtboxImageHelper::getImage(
+ $product->enabledVariants[ 0 ]->imageUrl,
+ 'list',
+ [
+ 'alt' => $product->category->lang->title . ' ' . $product->fullname,
+ 'title' => $product->category->lang->title . ' ' . $product->fullname,
+ 'class' => 'selected',
+ ]
+ ) ?>
-
Купить
+
Купить
-
К сравнению
@@ -57,9 +69,9 @@
- Бренд: = $product->brand->lang->title ?>
- getActiveProperties($product->category->id) as $group): ?>
+ getActiveProperties($product->category->id) as $group): ?>
-
- = $group->title ?> options as $option ) : ?> = $option->value ?>
+ = $group->title ?> options as $option ) : ?> = $option->value ?>
@@ -78,7 +90,7 @@
// есть скидка
echo '';
- if($product->enabledVariants[ 0 ]->price_old != 0 && $product->enabledVariants[ 0 ]->price_old != $product->enabledVariants[ 0 ]->price) {
+ if ($product->enabledVariants[ 0 ]->price_old != 0 && $product->enabledVariants[ 0 ]->price_old != $product->enabledVariants[ 0 ]->price) {
echo '' . $product->enabledVariants[ 0 ]->price_old . ' грн. ';
echo $product->enabledVariants[ 0 ]->price . ' грн.
';
} else {
diff --git a/common/modules/rubrication/models/TaxOption.php b/common/modules/rubrication/models/TaxOption.php
index ce088c1..73f063d 100755
--- a/common/modules/rubrication/models/TaxOption.php
+++ b/common/modules/rubrication/models/TaxOption.php
@@ -181,7 +181,7 @@
public function getProductVariants()
{
- return $this->hasMany(ProductVariant::className(), [ 'product_variant_id' => 'product_variant_id' ])
+ return $this->hasMany(ProductVariant::className(), [ 'id' => 'product_variant_id' ])
->viaTable('product_variant_option', [ 'option_id' => 'tax_option_id' ]);
}
}
diff --git a/common/widgets/views/basket_modal.php b/common/widgets/views/basket_modal.php
index bde7d58..615616e 100755
--- a/common/widgets/views/basket_modal.php
+++ b/common/widgets/views/basket_modal.php
@@ -9,13 +9,13 @@
-
-
+
- product->image )) : ?>
+ product->image )) : ?>
![<?= $item[ 'item' ]->product->image->alt ? $item[ 'item' ]->product->image->alt : $item[ 'item' ]->product->title ?>](/images/<?= $item[ 'item' ]->product->image->image ?>)
diff --git a/console/migrations/m160929_173535_create_product_unit_lang_table.php b/console/migrations/m160929_173535_create_product_unit_lang_table.php
index 8ae8e58..1728fdf 100755
--- a/console/migrations/m160929_173535_create_product_unit_lang_table.php
+++ b/console/migrations/m160929_173535_create_product_unit_lang_table.php
@@ -13,23 +13,47 @@
*/
public function up()
{
- $this->createTable('product_unit_lang', [
- 'product_unit_id' => $this->integer()
- ->notNull(),
- 'language_id' => $this->integer()
- ->notNull(),
- 'title' => $this->string()
- ->notNull(),
- 'short' => $this->string(),
- ]);
+ $this->createTable(
+ 'product_unit_lang',
+ [
+ 'product_unit_id' => $this->integer()
+ ->notNull(),
+ 'language_id' => $this->integer()
+ ->notNull(),
+ 'title' => $this->string()
+ ->notNull(),
+ 'short' => $this->string(),
+ ]
+ );
- $this->createIndex('product_unit_lang_product_unit_language_key', 'product_unit_lang', [
+ $this->createIndex(
+ 'product_unit_lang_product_unit_language_key',
+ 'product_unit_lang',
+ [
+ 'product_unit_id',
+ 'language_id',
+ ],
+ true
+ );
+
+ $this->addForeignKey(
+ 'product_unit_fk',
+ 'product_unit_lang',
'product_unit_id',
+ 'product_unit',
+ 'id',
+ 'CASCADE',
+ 'CASCADE'
+ );
+ $this->addForeignKey(
+ 'language_fk',
+ 'product_unit_lang',
'language_id',
- ], true);
-
- $this->addForeignKey('product_unit_fk', 'product_unit_lang', 'product_unit_id', 'product_unit', 'product_unit_id', 'CASCADE', 'CASCADE');
- $this->addForeignKey('language_fk', 'product_unit_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE');
+ 'language',
+ 'id',
+ 'RESTRICT',
+ 'CASCADE'
+ );
}
/**
diff --git a/console/migrations/m160929_175821_create_product_variant_lang_table.php b/console/migrations/m160929_175821_create_product_variant_lang_table.php
index 9a31c14..d72919b 100755
--- a/console/migrations/m160929_175821_create_product_variant_lang_table.php
+++ b/console/migrations/m160929_175821_create_product_variant_lang_table.php
@@ -13,21 +13,45 @@
*/
public function up()
{
- $this->createTable('product_variant_lang', [
- 'product_variant_id' => $this->integer()
- ->notNull(),
- 'language_id' => $this->integer()
- ->notNull(),
- 'title' => $this->string()
- ->notNull(),
- ]);
- $this->createIndex('product_variant_lang_product_variant_language_key', 'product_variant_lang', [
+ $this->createTable(
+ 'product_variant_lang',
+ [
+ 'product_variant_id' => $this->integer()
+ ->notNull(),
+ 'language_id' => $this->integer()
+ ->notNull(),
+ 'title' => $this->string()
+ ->notNull(),
+ ]
+ );
+ $this->createIndex(
+ 'product_variant_lang_product_variant_language_key',
+ 'product_variant_lang',
+ [
+ 'product_variant_id',
+ 'language_id',
+ ],
+ true
+ );
+
+ $this->addForeignKey(
+ 'product_variant_fk',
+ 'product_variant_lang',
'product_variant_id',
+ 'product_variant',
+ 'id',
+ 'CASCADE',
+ 'CASCADE'
+ );
+ $this->addForeignKey(
+ 'language_fk',
+ 'product_variant_lang',
'language_id',
- ], true);
-
- $this->addForeignKey('product_variant_fk', 'product_variant_lang', 'product_variant_id', 'product_variant', 'product_variant_id', 'CASCADE', 'CASCADE');
- $this->addForeignKey('language_fk', 'product_variant_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE');
+ 'language',
+ 'id',
+ 'RESTRICT',
+ 'CASCADE'
+ );
}
/**
diff --git a/console/migrations/m160930_100954_create_seo_lang_table.php b/console/migrations/m160930_100954_create_seo_lang_table.php
index 3b4f28c..1cc6b71 100755
--- a/console/migrations/m160930_100954_create_seo_lang_table.php
+++ b/console/migrations/m160930_100954_create_seo_lang_table.php
@@ -13,58 +13,114 @@
*/
public function up()
{
- $this->createTable('seo_lang', [
- 'seo_id' => $this->integer()
- ->notNull(),
- 'language_id' => $this->integer()
- ->notNull(),
- 'title' => $this->string(),
- 'meta_description' => $this->text(),
- 'h1' => $this->string(),
- 'meta' => $this->string(),
- 'seo_text' => $this->text(),
- ]);
- $this->createIndex('seo_lang_seo_language_key', 'seo_lang', [
- 'seo_id',
- 'language_id',
- ], true);
+ $this->createTable(
+ 'seo_lang',
+ [
+ 'seo_id' => $this->integer()
+ ->notNull(),
+ 'language_id' => $this->integer()
+ ->notNull(),
+ 'title' => $this->string(),
+ 'meta_description' => $this->text(),
+ 'h1' => $this->string(),
+ 'meta' => $this->string(),
+ 'seo_text' => $this->text(),
+ ]
+ );
+ $this->createIndex(
+ 'seo_lang_seo_language_key',
+ 'seo_lang',
+ [
+ 'seo_id',
+ 'language_id',
+ ],
+ true
+ );
- $this->addForeignKey('seo_fk', 'seo_lang', 'seo_id', 'seo', 'seo_id', 'CASCADE', 'CASCADE');
+ $this->addForeignKey('seo_fk', 'seo_lang', 'seo_id', 'seo', 'id', 'CASCADE', 'CASCADE');
$this->addForeignKey('language_fk', 'seo_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE');
- $this->createTable('seo_category_lang', [
- 'seo_category_id' => $this->integer()
- ->notNull(),
- 'language_id' => $this->integer()
- ->notNull(),
- 'title' => $this->string(),
- ]);
- $this->createIndex('seo_category_lang_seo_category_language_key', 'seo_category_lang', [
+ $this->createTable(
+ 'seo_category_lang',
+ [
+ 'seo_category_id' => $this->integer()
+ ->notNull(),
+ 'language_id' => $this->integer()
+ ->notNull(),
+ 'title' => $this->string(),
+ ]
+ );
+ $this->createIndex(
+ 'seo_category_lang_seo_category_language_key',
+ 'seo_category_lang',
+ [
+ 'seo_category_id',
+ 'language_id',
+ ],
+ true
+ );
+
+ $this->addForeignKey(
+ 'seo_category_fk',
+ 'seo_category_lang',
'seo_category_id',
+ 'seo_category',
+ 'id',
+ 'CASCADE',
+ 'CASCADE'
+ );
+ $this->addForeignKey(
+ 'language_fk',
+ 'seo_category_lang',
'language_id',
- ], true);
+ 'language',
+ 'id',
+ 'RESTRICT',
+ 'CASCADE'
+ );
+ $this->createTable(
+ 'seo_dynamic_lang',
+ [
+ 'seo_dynamic_id' => $this->integer()
+ ->notNull(),
+ 'language_id' => $this->integer()
+ ->notNull(),
+ 'title' => $this->string(),
+ 'meta_title' => $this->text(),
+ 'h1' => $this->string(),
+ 'key' => $this->string(),
+ 'meta' => $this->string(),
+ 'meta_description' => $this->text(),
+ 'seo_text' => $this->text(),
+ ]
+ );
+ $this->createIndex(
+ 'seo_dynamic_lang_seo_dynamic_language_key',
+ 'seo_dynamic_lang',
+ [
+ 'seo_dynamic_id',
+ 'language_id',
+ ],
+ true
+ );
- $this->addForeignKey('seo_category_fk', 'seo_category_lang', 'seo_category_id', 'seo_category', 'seo_category_id', 'CASCADE', 'CASCADE');
- $this->addForeignKey('language_fk', 'seo_category_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE');
- $this->createTable('seo_dynamic_lang', [
- 'seo_dynamic_id' => $this->integer()
- ->notNull(),
- 'language_id' => $this->integer()
- ->notNull(),
- 'title' => $this->string(),
- 'meta_title' => $this->text(),
- 'h1' => $this->string(),
- 'key' => $this->string(),
- 'meta' => $this->string(),
- 'meta_description' => $this->text(),
- 'seo_text' => $this->text(),
- ]);
- $this->createIndex('seo_dynamic_lang_seo_dynamic_language_key', 'seo_dynamic_lang', [
+ $this->addForeignKey(
+ 'seo_dynamic_fk',
+ 'seo_dynamic_lang',
'seo_dynamic_id',
+ 'seo_dynamic',
+ 'id',
+ 'CASCADE',
+ 'CASCADE'
+ );
+ $this->addForeignKey(
+ 'language_fk',
+ 'seo_dynamic_lang',
'language_id',
- ], true);
-
- $this->addForeignKey('seo_dynamic_fk', 'seo_dynamic_lang', 'seo_dynamic_id', 'seo_dynamic', 'seo_dynamic_id', 'CASCADE', 'CASCADE');
- $this->addForeignKey('language_fk', 'seo_dynamic_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE');
+ 'language',
+ 'id',
+ 'RESTRICT',
+ 'CASCADE'
+ );
}
/**
diff --git a/console/migrations/m160930_133757_create_service_lang_table.php b/console/migrations/m160930_133757_create_service_lang_table.php
index 327a554..db3a015 100755
--- a/console/migrations/m160930_133757_create_service_lang_table.php
+++ b/console/migrations/m160930_133757_create_service_lang_table.php
@@ -13,26 +13,34 @@
*/
public function up()
{
- $this->createTable('service_lang', [
- 'service_id' => $this->integer()
- ->notNull(),
- 'language_id' => $this->integer()
- ->notNull(),
- 'title' => $this->string()
- ->notNull(),
- 'body' => $this->text()
- ->notNull(),
- 'seo_text' => $this->text(),
- 'meta_title' => $this->string(),
- 'meta_description' => $this->string(),
- 'h1' => $this->string(),
- ]);
- $this->createIndex('service_lang_service_language_key', 'service_lang', [
- 'service_id',
- 'language_id',
- ], true);
+ $this->createTable(
+ 'service_lang',
+ [
+ 'service_id' => $this->integer()
+ ->notNull(),
+ 'language_id' => $this->integer()
+ ->notNull(),
+ 'title' => $this->string()
+ ->notNull(),
+ 'body' => $this->text()
+ ->notNull(),
+ 'seo_text' => $this->text(),
+ 'meta_title' => $this->string(),
+ 'meta_description' => $this->string(),
+ 'h1' => $this->string(),
+ ]
+ );
+ $this->createIndex(
+ 'service_lang_service_language_key',
+ 'service_lang',
+ [
+ 'service_id',
+ 'language_id',
+ ],
+ true
+ );
- $this->addForeignKey('service_fk', 'service_lang', 'service_id', 'service', 'service_id', 'CASCADE', 'CASCADE');
+ $this->addForeignKey('service_fk', 'service_lang', 'service_id', 'service', 'id', 'CASCADE', 'CASCADE');
$this->addForeignKey('language_fk', 'service_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE');
}
diff --git a/console/migrations/m160930_142752_create_slider_image_lang_table.php b/console/migrations/m160930_142752_create_slider_image_lang_table.php
index e19f38f..200adfb 100755
--- a/console/migrations/m160930_142752_create_slider_image_lang_table.php
+++ b/console/migrations/m160930_142752_create_slider_image_lang_table.php
@@ -13,21 +13,45 @@
*/
public function up()
{
- $this->createTable('slider_image_lang', [
- 'slider_image_id' => $this->integer()
- ->notNull(),
- 'language_id' => $this->integer()
- ->notNull(),
- 'title' => $this->string(),
- 'alt' => $this->string(),
- ]);
- $this->createIndex('slider_image_lang_slider_image_language_key', 'slider_image_lang', [
+ $this->createTable(
+ 'slider_image_lang',
+ [
+ 'slider_image_id' => $this->integer()
+ ->notNull(),
+ 'language_id' => $this->integer()
+ ->notNull(),
+ 'title' => $this->string(),
+ 'alt' => $this->string(),
+ ]
+ );
+ $this->createIndex(
+ 'slider_image_lang_slider_image_language_key',
+ 'slider_image_lang',
+ [
+ 'slider_image_id',
+ 'language_id',
+ ],
+ true
+ );
+
+ $this->addForeignKey(
+ 'slider_image_fk',
+ 'slider_image_lang',
'slider_image_id',
+ 'slider_image',
+ 'id',
+ 'CASCADE',
+ 'CASCADE'
+ );
+ $this->addForeignKey(
+ 'language_fk',
+ 'slider_image_lang',
'language_id',
- ], true);
-
- $this->addForeignKey('slider_image_fk', 'slider_image_lang', 'slider_image_id', 'slider_image', 'slider_image_id', 'CASCADE', 'CASCADE');
- $this->addForeignKey('language_fk', 'slider_image_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE');
+ 'language',
+ 'id',
+ 'RESTRICT',
+ 'CASCADE'
+ );
}
/**
diff --git a/console/migrations/m161011_104931_create_stock_lang_table.php b/console/migrations/m161011_104931_create_stock_lang_table.php
index 1732357..f9953e3 100755
--- a/console/migrations/m161011_104931_create_stock_lang_table.php
+++ b/console/migrations/m161011_104931_create_stock_lang_table.php
@@ -1,39 +1,47 @@
createTable('stock_lang', [
- 'stock_id' => $this->integer()
- ->notNull(),
- 'language_id' => $this->integer()
- ->notNull(),
- 'title' => $this->string()
- ->notNull(),
- ]);
- $this->createIndex('stock_lang_stock_language_key', 'stock_lang', [
- 'stock_id',
- 'language_id',
- ], true);
+ /**
+ * @inheritdoc
+ */
+ public function up()
+ {
+ $this->createTable(
+ 'stock_lang',
+ [
+ 'stock_id' => $this->integer()
+ ->notNull(),
+ 'language_id' => $this->integer()
+ ->notNull(),
+ 'title' => $this->string()
+ ->notNull(),
+ ]
+ );
+ $this->createIndex(
+ 'stock_lang_stock_language_key',
+ 'stock_lang',
+ [
+ 'stock_id',
+ 'language_id',
+ ],
+ true
+ );
+
+ $this->addForeignKey('stock_fk', 'stock_lang', 'stock_id', 'stock', 'id', 'CASCADE', 'CASCADE');
+ $this->addForeignKey('language_fk', 'stock_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE');
+ }
- $this->addForeignKey('stock_fk', 'stock_lang', 'stock_id', 'stock', 'stock_id', 'CASCADE', 'CASCADE');
- $this->addForeignKey('language_fk', 'stock_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE');
+ /**
+ * @inheritdoc
+ */
+ public function down()
+ {
+ $this->dropTable('stock_lang');
+ }
}
-
- /**
- * @inheritdoc
- */
- public function down()
- {
- $this->dropTable('stock_lang');
- }
-}
diff --git a/frontend/web/js/artbox_basket.js b/frontend/web/js/artbox_basket.js
index 13a014b..bf3476b 100755
--- a/frontend/web/js/artbox_basket.js
+++ b/frontend/web/js/artbox_basket.js
@@ -1,64 +1,86 @@
-var ArtboxBasket = (function () {
+var ArtboxBasket = (function() {
function ArtboxBasket() {
this.init(true, true);
}
- Object.defineProperty(ArtboxBasket.prototype, "items", {
- get: function () {
- return this._items;
- },
- enumerable: true,
- configurable: true
- });
- ArtboxBasket.prototype.init = function (update_modal, update_cart) {
- $.get('/basket', function (data) {
- this._items = data.basket;
- if (update_modal) {
- this.updateModal(data.modal, false);
- }
- if (update_cart) {
- this.updateCart(data.cart);
- }
- }.bind(this), 'json').fail(function () {
- console.error('Basket cannot be init');
- });
+
+ Object.defineProperty(
+ ArtboxBasket.prototype, "items", {
+ get: function() {
+ return this._items;
+ },
+ enumerable: true,
+ configurable: true
+ }
+ );
+ ArtboxBasket.prototype.init = function(update_modal, update_cart) {
+ $.get(
+ '/basket', function(data) {
+ this._items = data.basket;
+ if (update_modal) {
+ this.updateModal(data.modal, false);
+ }
+ if (update_cart) {
+ this.updateCart(data.cart);
+ }
+ }.bind(this), 'json'
+ )
+ .fail(
+ function() {
+ console.error('Basket cannot be init');
+ }
+ );
};
- ArtboxBasket.prototype.add = function (product_variant_id) {
- $.post('/basket/add?product_variant_id=' + product_variant_id, function (data) {
- this._items = data.basket;
- this.updateModal(data.modal, data.cart, true);
- showForm();
- }.bind(this), 'json').fail(function (xhr, status, error) {
- console.error(error);
- });
+ ArtboxBasket.prototype.add = function(product_variant_id) {
+ $.post(
+ '/basket/add?product_variant_id=' + product_variant_id, function(data) {
+ this._items = data.basket;
+ this.updateModal(data.modal, data.cart, true);
+ showForm();
+ }.bind(this), 'json'
+ )
+ .fail(
+ function(xhr, status, error) {
+ console.error(error);
+ }
+ );
};
- ArtboxBasket.prototype.remove = function (product_variant_id) {
- $.post('/basket/remove?product_variant_id=' + product_variant_id, function (data) {
- this._items = data.basket;
- this.updateCart(data.cart);
- // this.updateModal(data.modal, data.cart, true);
- }.bind(this), 'json').fail(function (xhr, status, error) {
- console.error(error);
- });
+ ArtboxBasket.prototype.remove = function(product_variant_id) {
+ $.post(
+ '/basket/remove?product_variant_id=' + product_variant_id, function(data) {
+ this._items = data.basket;
+ this.updateCart(data.cart);
+ // this.updateModal(data.modal, data.cart, true);
+ }.bind(this), 'json'
+ )
+ .fail(
+ function(xhr, status, error) {
+ console.error(error);
+ }
+ );
};
- ArtboxBasket.prototype.updateModal = function (modal, cart_html, show) {
- if (show === void 0) { show = false; }
+ ArtboxBasket.prototype.updateModal = function(modal, cart_html, show) {
+ if (show === void 0) {
+ show = false;
+ }
var modalBox = $('#modal_form-2');
modalBox.html(modal);
if (cart_html) {
this.updateCart(cart_html);
}
};
- ArtboxBasket.prototype.updateCart = function (cart_html) {
+ ArtboxBasket.prototype.updateCart = function(cart_html) {
var cart = $('.question-form ');
cart.html(cart_html);
};
- Object.defineProperty(ArtboxBasket.prototype, "count", {
- get: function () {
- return Object.keys(this._items).length;
- },
- enumerable: true,
- configurable: true
- });
+ Object.defineProperty(
+ ArtboxBasket.prototype, "count", {
+ get: function() {
+ return Object.keys(this._items).length;
+ },
+ enumerable: true,
+ configurable: true
+ }
+ );
return ArtboxBasket;
}());
//# sourceMappingURL=artbox_basket.js.map
\ No newline at end of file
--
libgit2 0.21.4