Commit 871a734907eeacc25c625fbcf0fdabcab2905de8

Authored by Administrator
1 parent 52aea36a

big commti

backend/controllers/CategoryController.php
@@ -97,7 +97,7 @@ class CategoryController extends Controller @@ -97,7 +97,7 @@ class CategoryController extends Controller
97 } 97 }
98 return $this->render('create', [ 98 return $this->render('create', [
99 'model' => $model, 99 'model' => $model,
100 - 'categories' => ArtboxTreeHelper::treeMap(Category::find()->with('categoryName')->getTree(), 'category_id', 'categoryName.value', '.') 100 + 'categories' => ArtboxTreeHelper::treeMap(Category::find()->getTree(), 'category_id', 'name', '.')
101 ]); 101 ]);
102 } 102 }
103 } 103 }
@@ -125,7 +125,7 @@ class CategoryController extends Controller @@ -125,7 +125,7 @@ class CategoryController extends Controller
125 } else { 125 } else {
126 return $this->render('update', [ 126 return $this->render('update', [
127 'model' => $model, 127 'model' => $model,
128 - 'categories' => ArtboxTreeHelper::treeMap(Category::find()->with('categoryName')->getTree(), 'category_id', 'categoryName.value', '.') 128 + 'categories' => ArtboxTreeHelper::treeMap(Category::find()->getTree(), 'category_id', 'name', '.')
129 ]); 129 ]);
130 } 130 }
131 } 131 }
backend/controllers/SiteController.php
@@ -2,9 +2,7 @@ @@ -2,9 +2,7 @@
2 namespace backend\controllers; 2 namespace backend\controllers;
3 use developeruz\db_rbac\behaviors\AccessBehavior; 3 use developeruz\db_rbac\behaviors\AccessBehavior;
4 use common\modules\product\models\Brand; 4 use common\modules\product\models\Brand;
5 -use common\modules\product\models\BrandName;  
6 use common\modules\product\models\Category; 5 use common\modules\product\models\Category;
7 -use common\modules\product\models\CategoryName;  
8 use common\modules\product\models\Product; 6 use common\modules\product\models\Product;
9 use common\modules\product\models\ProductVariant; 7 use common\modules\product\models\ProductVariant;
10 use common\modules\product\models\ProductVariantType; 8 use common\modules\product\models\ProductVariantType;
@@ -199,7 +197,7 @@ class SiteController extends Controller @@ -199,7 +197,7 @@ class SiteController extends Controller
199 } 197 }
200 198
201 // ==== Set category ==== 199 // ==== Set category ====
202 - if ( ($category = CategoryName::find()->filterWhere(['ilike', 'value', trim($catalog_name)])->one()) !== null ) { 200 + if ( ($category = Category::find()->filterWhere(['ilike', 'name', trim($catalog_name)])->one()) !== null ) {
203 $_product->categories = [$category->category_id]; 201 $_product->categories = [$category->category_id];
204 } else { 202 } else {
205 // Create category 203 // Create category
@@ -211,7 +209,7 @@ class SiteController extends Controller @@ -211,7 +209,7 @@ class SiteController extends Controller
211 209
212 // ===== Set brand ==== 210 // ===== Set brand ====
213 if ( $brand_name ) { 211 if ( $brand_name ) {
214 - if ( ($brand = BrandName::find()->filterWhere(['ilike', 'value', trim($brand_name)])->one()) !== null ) { 212 + if ( ($brand = Brand::find()->filterWhere(['ilike', 'name', trim($brand_name)])->one()) !== null ) {
215 $_product->brand_id = $brand->brand_id; 213 $_product->brand_id = $brand->brand_id;
216 } else { 214 } else {
217 // Create brand 215 // Create brand
common/modules/product/controllers/ManageController.php
@@ -8,7 +8,6 @@ use common\modules\product\models\Export; @@ -8,7 +8,6 @@ use common\modules\product\models\Export;
8 use common\modules\product\models\Import; 8 use common\modules\product\models\Import;
9 use common\modules\product\models\ProductImage; 9 use common\modules\product\models\ProductImage;
10 use common\modules\product\models\ProductVariant; 10 use common\modules\product\models\ProductVariant;
11 -use common\modules\product\models\RemoteProductsSearch;  
12 use Yii; 11 use Yii;
13 use common\modules\product\models\Product; 12 use common\modules\product\models\Product;
14 use common\modules\product\models\ProductSearch; 13 use common\modules\product\models\ProductSearch;
@@ -16,8 +15,6 @@ use yii\web\Controller; @@ -16,8 +15,6 @@ use yii\web\Controller;
16 use yii\web\NotFoundHttpException; 15 use yii\web\NotFoundHttpException;
17 use yii\filters\VerbFilter; 16 use yii\filters\VerbFilter;
18 use common\modules\product\models\Brand; 17 use common\modules\product\models\Brand;
19 -use common\modules\product\models\BrandName;  
20 -use common\modules\product\models\RemoteProducts;  
21 use yii\web\UploadedFile; 18 use yii\web\UploadedFile;
22 19
23 /** 20 /**
common/modules/product/helpers/FilterHelper.php
@@ -2,9 +2,7 @@ @@ -2,9 +2,7 @@
2 2
3 namespace common\modules\product\helpers; 3 namespace common\modules\product\helpers;
4 4
5 -use common\modules\product\models\Product;  
6 -use common\modules\product\models\BrandName;  
7 -use common\modules\product\models\CategoryName; 5 +
8 use common\modules\rubrication\models\TaxGroup; 6 use common\modules\rubrication\models\TaxGroup;
9 use yii\base\Object; 7 use yii\base\Object;
10 use Yii; 8 use Yii;
common/modules/product/helpers/ProductHelper.php
@@ -6,8 +6,6 @@ @@ -6,8 +6,6 @@
6 use common\modules\product\models\Category; 6 use common\modules\product\models\Category;
7 use common\modules\product\models\Product; 7 use common\modules\product\models\Product;
8 use common\modules\product\models\ProductVariant; 8 use common\modules\product\models\ProductVariant;
9 - use common\modules\product\models\BrandName;  
10 - use common\modules\product\models\CategoryName;  
11 use yii\base\Object; 9 use yii\base\Object;
12 use Yii; 10 use Yii;
13 use yii\db\ActiveQuery; 11 use yii\db\ActiveQuery;
@@ -202,12 +200,12 @@ @@ -202,12 +200,12 @@
202 ]); 200 ]);
203 $query->orFilterWhere([ 201 $query->orFilterWhere([
204 'ilike', 202 'ilike',
205 - BrandName::tableName() . '.value', 203 + Brand::tableName() . '.name',
206 $keyword, 204 $keyword,
207 ]); 205 ]);
208 $query->orFilterWhere([ 206 $query->orFilterWhere([
209 'ilike', 207 'ilike',
210 - CategoryName::tableName() . '.value', 208 + Category::tableName() . '.name',
211 $keyword, 209 $keyword,
212 ]); 210 ]);
213 $query->orFilterWhere([ 211 $query->orFilterWhere([
common/modules/product/models/Brand.php
@@ -19,6 +19,7 @@ use Yii; @@ -19,6 +19,7 @@ use Yii;
19 * @property string $meta_desc 19 * @property string $meta_desc
20 * @property string $meta_robots 20 * @property string $meta_robots
21 * @property string $seo_text 21 * @property string $seo_text
  22 + * @property string $name
22 * 23 *
23 * @property BrandName $brandName 24 * @property BrandName $brandName
24 * @property BrandName[] $brandNames 25 * @property BrandName[] $brandNames
@@ -30,26 +31,6 @@ class Brand extends \yii\db\ActiveRecord @@ -30,26 +31,6 @@ class Brand extends \yii\db\ActiveRecord
30 31
31 public $_items_count = 0; 32 public $_items_count = 0;
32 33
33 - public function behaviors()  
34 - {  
35 - return [  
36 - 'artboxsynonym' => [  
37 - 'class' => ArtboxSynonymBehavior::className(),  
38 - 'keyNameValue' => 'brand_name_id',  
39 - 'valueModel' => BrandName::className(),  
40 - 'valueOptionId' => 'brand_id',  
41 - 'valueFields' => [ // postKey => DBFieldName  
42 - 'name' => 'value'  
43 - ],  
44 - 'slug' => [  
45 - 'valueKeyName' => 'value',  
46 - 'slugKeyName' => 'alias',  
47 - 'translit' => true  
48 - ],  
49 - ],  
50 - ];  
51 - }  
52 -  
53 /** 34 /**
54 * @inheritdoc 35 * @inheritdoc
55 */ 36 */
@@ -94,21 +75,7 @@ class Brand extends \yii\db\ActiveRecord @@ -94,21 +75,7 @@ class Brand extends \yii\db\ActiveRecord
94 ]; 75 ];
95 } 76 }
96 77
97 - /**  
98 - * @return \yii\db\ActiveQuery  
99 - */  
100 - public function getBrandName()  
101 - {  
102 - return $this->hasOne(BrandName::className(), ['brand_name_id' => 'brand_name_id']);  
103 - }  
104 78
105 - /**  
106 - * @return \yii\db\ActiveQuery  
107 - */  
108 - public function getBrandNames()  
109 - {  
110 - return $this->hasMany(BrandName::className(), ['brand_id' => 'brand_id']);  
111 - }  
112 79
113 /** 80 /**
114 * @return \yii\db\ActiveQuery 81 * @return \yii\db\ActiveQuery
@@ -118,10 +85,6 @@ class Brand extends \yii\db\ActiveRecord @@ -118,10 +85,6 @@ class Brand extends \yii\db\ActiveRecord
118 return $this->hasMany(Product::className(), ['brand_id' => 'brand_id']); 85 return $this->hasMany(Product::className(), ['brand_id' => 'brand_id']);
119 } 86 }
120 87
121 - public function getName() {  
122 - return empty($this->brand_name_id) ? null : $this->brandName->value;  
123 - }  
124 -  
125 public function getImageFile() { 88 public function getImageFile() {
126 return empty($this->image) ? null : Yii::getAlias('@imagesDir/brands/'. $this->image); 89 return empty($this->image) ? null : Yii::getAlias('@imagesDir/brands/'. $this->image);
127 } 90 }
common/modules/product/models/BrandName.php deleted
1 -<?php  
2 -  
3 -namespace common\modules\product\models;  
4 -  
5 -use Yii;  
6 -  
7 -/**  
8 - * This is the model class for table "brand_name".  
9 - *  
10 - * @property integer $brand_name_id  
11 - * @property integer $brand_id  
12 - * @property string $value  
13 - *  
14 - * @property Brand[] $brands  
15 - * @property Brand $brand  
16 - */  
17 -class BrandName extends \yii\db\ActiveRecord  
18 -{  
19 - /**  
20 - * @inheritdoc  
21 - */  
22 - public static function tableName()  
23 - {  
24 - return 'brand_name';  
25 - }  
26 -  
27 - /**  
28 - * @inheritdoc  
29 - */  
30 - public function rules()  
31 - {  
32 - return [  
33 - [['brand_id'], 'integer'],  
34 - [['value'], 'string', 'max' => 250],  
35 -// [['brand_id'], 'exist', 'skipOnError' => true, 'targetClass' => Brand::className(), 'targetAttribute' => ['brand_id' => 'brand_id']],  
36 - ];  
37 - }  
38 -  
39 - /**  
40 - * @inheritdoc  
41 - */  
42 - public function attributeLabels()  
43 - {  
44 - return [  
45 - 'brand_name_id' => Yii::t('product', 'Brand Name ID'),  
46 - 'brand_id' => Yii::t('product', 'Brand ID'),  
47 - 'value' => Yii::t('product', 'Value'),  
48 - ];  
49 - }  
50 -  
51 - /**  
52 - * @return \yii\db\ActiveQuery  
53 - */  
54 - public function getBrands()  
55 - {  
56 - return $this->hasMany(Brand::className(), ['brand_name_id' => 'brand_name_id']);  
57 - }  
58 -  
59 - /**  
60 - * @return \yii\db\ActiveQuery  
61 - */  
62 - public function getBrand()  
63 - {  
64 - return $this->hasOne(Brand::className(), ['brand_id' => 'brand_id']);  
65 - }  
66 -}  
common/modules/product/models/BrandSearch.php
@@ -81,8 +81,7 @@ class BrandSearch extends Brand @@ -81,8 +81,7 @@ class BrandSearch extends Brand
81 ->andFilterWhere(['ilike', 'meta_robots', $this->meta_robots]) 81 ->andFilterWhere(['ilike', 'meta_robots', $this->meta_robots])
82 ->andFilterWhere(['ilike', 'seo_text', $this->seo_text]); 82 ->andFilterWhere(['ilike', 'seo_text', $this->seo_text]);
83 if (!empty($this->brand_name)) { 83 if (!empty($this->brand_name)) {
84 - $query->joinWith('brandName');  
85 - $query->andFilterWhere(['ilike', 'brand_name.value', $this->brand_name]); 84 + $query->andFilterWhere(['ilike', 'name', $this->brand_name]);
86 } 85 }
87 86
88 $query->orderBy('brand_id', 'asc'); 87 $query->orderBy('brand_id', 'asc');
@@ -110,8 +109,7 @@ class BrandSearch extends Brand @@ -110,8 +109,7 @@ class BrandSearch extends Brand
110 Brand::tableName() .'.*' 109 Brand::tableName() .'.*'
111 ]) 110 ])
112 ->innerJoin(Product::tableName(), Product::tableName() .'.brand_id='. Brand::tableName() .'.brand_id') 111 ->innerJoin(Product::tableName(), Product::tableName() .'.brand_id='. Brand::tableName() .'.brand_id')
113 - ->innerJoin(ProductCategory::tableName(), ProductCategory::tableName() .'.product_id='. Product::tableName() .'.product_id')  
114 - ->with(['brandName']); 112 + ->innerJoin(ProductCategory::tableName(), ProductCategory::tableName() .'.product_id='. Product::tableName() .'.product_id');
115 113
116 114
117 // $queryCount = Product::find() 115 // $queryCount = Product::find()
@@ -157,7 +155,6 @@ class BrandSearch extends Brand @@ -157,7 +155,6 @@ class BrandSearch extends Brand
157 public static function findByAlias($alias) { 155 public static function findByAlias($alias) {
158 /** @var CategoryQuery $query */ 156 /** @var CategoryQuery $query */
159 $query = Brand::find() 157 $query = Brand::find()
160 - ->with('brandName')  
161 ->andFilterWhere(['alias' => $alias]); 158 ->andFilterWhere(['alias' => $alias]);
162 if (($model = $query->one()) !== null) { 159 if (($model = $query->one()) !== null) {
163 return $model; 160 return $model;
common/modules/product/models/Category.php
@@ -2,13 +2,13 @@ @@ -2,13 +2,13 @@
2 2
3 namespace common\modules\product\models; 3 namespace common\modules\product\models;
4 4
5 -use common\behaviors\RuSlug; 5 +
6 use common\components\artboxtree\ArtboxTreeBehavior; 6 use common\components\artboxtree\ArtboxTreeBehavior;
7 use common\components\artboxtree\ArtboxTreeHelper; 7 use common\components\artboxtree\ArtboxTreeHelper;
8 -use common\modules\rubrication\behaviors\ArtboxSynonymBehavior; 8 +
9 use common\modules\rubrication\models\TaxGroup; 9 use common\modules\rubrication\models\TaxGroup;
10 use Yii; 10 use Yii;
11 -use yii\base\ErrorException; 11 +
12 use yii\db\Query; 12 use yii\db\Query;
13 13
14 /** 14 /**
@@ -28,6 +28,7 @@ use yii\db\Query; @@ -28,6 +28,7 @@ use yii\db\Query;
28 * @property integer $product_unit_id 28 * @property integer $product_unit_id
29 * @property string $alias 29 * @property string $alias
30 * @property boolean $populary 30 * @property boolean $populary
  31 + * @property boolean $name
31 * 32 *
32 * @property CategoryName $categoryName 33 * @property CategoryName $categoryName
33 * @property Product[] $products 34 * @property Product[] $products
@@ -46,21 +47,7 @@ class Category extends \yii\db\ActiveRecord @@ -46,21 +47,7 @@ class Category extends \yii\db\ActiveRecord
46 'class' => ArtboxTreeBehavior::className(), 47 'class' => ArtboxTreeBehavior::className(),
47 'keyNameGroup' => null, 48 'keyNameGroup' => null,
48 'keyNamePath' => 'path', 49 'keyNamePath' => 'path',
49 - ],  
50 - 'artboxsynonym' => [  
51 - 'class' => ArtboxSynonymBehavior::className(),  
52 - 'keyNameValue' => 'category_name_id',  
53 - 'valueModel' => CategoryName::className(),  
54 - 'valueOptionId' => 'category_id',  
55 - 'valueFields' => [ // postKey => DBFieldName  
56 - 'name' => 'value'  
57 - ],  
58 - 'slug' => [  
59 - 'valueKeyName' => 'value',  
60 - 'slugKeyName' => 'alias',  
61 - 'translit' => true  
62 - ]  
63 - ], 50 + ]
64 51
65 ]; 52 ];
66 } 53 }
@@ -87,7 +74,6 @@ class Category extends \yii\db\ActiveRecord @@ -87,7 +74,6 @@ class Category extends \yii\db\ActiveRecord
87 [['alias', 'name'], 'string', 'max' => 250], 74 [['alias', 'name'], 'string', 'max' => 250],
88 [['populary'], 'boolean'], 75 [['populary'], 'boolean'],
89 [['group_to_category', 'remote_category'], 'safe'], 76 [['group_to_category', 'remote_category'], 'safe'],
90 - [['category_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => CategoryName::className(), 'targetAttribute' => ['category_name_id' => 'category_name_id']],  
91 [['imageUpload'], 'safe'], 77 [['imageUpload'], 'safe'],
92 [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], 78 [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'],
93 ]; 79 ];
@@ -137,13 +123,6 @@ class Category extends \yii\db\ActiveRecord @@ -137,13 +123,6 @@ class Category extends \yii\db\ActiveRecord
137 // return $this->getRelations('product_categories'); 123 // return $this->getRelations('product_categories');
138 } 124 }
139 125
140 - /**  
141 - * @return \yii\db\ActiveQuery  
142 - */  
143 - public function getCategoryNames()  
144 - {  
145 - return $this->hasMany(CategoryName::className(), ['category_id' => 'category_id']);  
146 - }  
147 126
148 /** 127 /**
149 * @return \yii\db\ActiveQuery 128 * @return \yii\db\ActiveQuery
@@ -153,10 +132,6 @@ class Category extends \yii\db\ActiveRecord @@ -153,10 +132,6 @@ class Category extends \yii\db\ActiveRecord
153 return $this->hasMany(ProductCategory::className(), ['category_id' => 'category_id']); 132 return $this->hasMany(ProductCategory::className(), ['category_id' => 'category_id']);
154 } 133 }
155 134
156 - public function getTaxGroups()  
157 - {  
158 - return $this->getRelations('tax_group_to_category');  
159 - }  
160 135
161 public function getTaxGroupsByLevel($level) 136 public function getTaxGroupsByLevel($level)
162 { 137 {
@@ -177,14 +152,8 @@ class Category extends \yii\db\ActiveRecord @@ -177,14 +152,8 @@ class Category extends \yii\db\ActiveRecord
177 } 152 }
178 } 153 }
179 154
180 - public function getCategoryName()  
181 - {  
182 - return $this->hasOne(CategoryName::className(), ['category_name_id' => 'category_name_id']);  
183 - }  
184 155
185 - public function getName() {  
186 - return empty($this->categoryName) ? null : $this->categoryName->value;  
187 - } 156 +
188 157
189 public function getImageFile() { 158 public function getImageFile() {
190 return empty($this->image) ? '/images/no_photo.png' : Yii::getAlias('@imagesDir/categories/'. $this->image); 159 return empty($this->image) ? '/images/no_photo.png' : Yii::getAlias('@imagesDir/categories/'. $this->image);
@@ -216,22 +185,13 @@ class Category extends \yii\db\ActiveRecord @@ -216,22 +185,13 @@ class Category extends \yii\db\ActiveRecord
216 } 185 }
217 } 186 }
218 ProductCategory::deleteAll(['category_id' => $this->category_id]); 187 ProductCategory::deleteAll(['category_id' => $this->category_id]);
219 - CategoryName::deleteAll(['category_id' => $this->category_id]);  
220 return true; 188 return true;
221 } 189 }
222 -  
223 public function getActiveFilters() { 190 public function getActiveFilters() {
224 $query1 = (new Query()) 191 $query1 = (new Query())
225 ->distinct() 192 ->distinct()
226 ->select([ 193 ->select([
227 - 'option_id',  
228 - 'tax_option.*',  
229 - 'tax_group.*',  
230 - 'tax_option.alias as option_alias',  
231 - 'tax_group.alias as group_alias',  
232 - 'tax_value_string.value as value',  
233 - 'tax_option.sort AS tax_option_sort',  
234 - 'tax_group.sort AS tax_group_sort', 194 + 'option_id'
235 ]) 195 ])
236 ->from('tax_option') 196 ->from('tax_option')
237 ->innerJoin('product_variant_option', 'tax_option.tax_option_id = product_variant_option.option_id') 197 ->innerJoin('product_variant_option', 'tax_option.tax_option_id = product_variant_option.option_id')
@@ -242,18 +202,11 @@ class Category extends \yii\db\ActiveRecord @@ -242,18 +202,11 @@ class Category extends \yii\db\ActiveRecord
242 ->innerJoin('tax_value_string', 'tax_value_string.tax_option_id = tax_option.tax_option_id') 202 ->innerJoin('tax_value_string', 'tax_value_string.tax_option_id = tax_option.tax_option_id')
243 ->where(['product_category.category_id' => $this->category_id, 'tax_group.is_filter' => TRUE]) 203 ->where(['product_category.category_id' => $this->category_id, 'tax_group.is_filter' => TRUE])
244 ->andWhere(['!=', 'product_variant.stock', 0]); 204 ->andWhere(['!=', 'product_variant.stock', 0]);
245 - 205 +
246 $query2 = (new Query()) 206 $query2 = (new Query())
247 ->distinct() 207 ->distinct()
248 ->select([ 208 ->select([
249 - 'option_id',  
250 - 'tax_option.*',  
251 - 'tax_group.*',  
252 - 'tax_option.alias as option_alias',  
253 - 'tax_group.alias as group_alias',  
254 - 'tax_value_string.value as value',  
255 - 'tax_option.sort AS tax_option_sort',  
256 - 'tax_group.sort AS tax_group_sort', 209 + 'option_id'
257 ]) 210 ])
258 ->from('tax_option') 211 ->from('tax_option')
259 ->innerJoin('product_option', 'tax_option.tax_option_id = product_option.option_id') 212 ->innerJoin('product_option', 'tax_option.tax_option_id = product_option.option_id')
@@ -265,9 +218,20 @@ class Category extends \yii\db\ActiveRecord @@ -265,9 +218,20 @@ class Category extends \yii\db\ActiveRecord
265 ->where(['product_category.category_id' => $this->category_id, 'tax_group.is_filter' => TRUE]) 218 ->where(['product_category.category_id' => $this->category_id, 'tax_group.is_filter' => TRUE])
266 ->andWhere(['!=', 'product_variant.stock', 0]); 219 ->andWhere(['!=', 'product_variant.stock', 0]);
267 $query3 = (new Query()) 220 $query3 = (new Query())
268 - ->select('*')  
269 - ->from(['subquery' => $query1->union($query2)])  
270 - ->orderBy('tax_group_sort, tax_option_sort'); 221 + ->select([
  222 + 'tax_option.*',
  223 + 'tax_group.*',
  224 + 'tax_option.alias as option_alias',
  225 + 'tax_group.alias as group_alias',
  226 + 'tax_value_string.value as value',
  227 + 'tax_option.sort AS tax_option_sort',
  228 + 'tax_group.sort AS tax_group_sort',
  229 + ])
  230 + ->from(['tax_option' ])
  231 + ->where(['tax_option.tax_option_id'=>$query1->union($query2)])
  232 + ->innerJoin('tax_group','tax_group.tax_group_id = tax_option.tax_group_id')
  233 + ->innerJoin('tax_value_string', 'tax_value_string.tax_option_id = tax_option.tax_option_id')
  234 + ->orderBy('tax_option.sort, tax_group.sort');
271 return $query3; 235 return $query3;
272 } 236 }
273 237
common/modules/product/models/CategoryName.php deleted
1 -<?php  
2 -  
3 -namespace common\modules\product\models;  
4 -  
5 -use Yii;  
6 -  
7 -/**  
8 - * This is the model class for table "category_name".  
9 - *  
10 - * @property integer $category_name_id  
11 - * @property integer $category_id  
12 - * @property string $value  
13 - *  
14 - * @property Category[] $categories  
15 - * @property Category $category  
16 - */  
17 -class CategoryName extends \yii\db\ActiveRecord  
18 -{  
19 - /**  
20 - * @inheritdoc  
21 - */  
22 - public static function tableName()  
23 - {  
24 - return 'category_name';  
25 - }  
26 -  
27 - /**  
28 - * @inheritdoc  
29 - */  
30 - public function rules()  
31 - {  
32 - return [  
33 - [['category_id'], 'integer'],  
34 - [['value'], 'string', 'max' => 250],  
35 - [['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => Category::className(), 'targetAttribute' => ['category_id' => 'category_id']],  
36 - ];  
37 - }  
38 -  
39 - /**  
40 - * @inheritdoc  
41 - */  
42 - public function attributeLabels()  
43 - {  
44 - return [  
45 - 'category_name_id' => Yii::t('product', 'Category Name ID'),  
46 - 'category_id' => Yii::t('product', 'Category ID'),  
47 - 'value' => Yii::t('product', 'Value'),  
48 - ];  
49 - }  
50 -  
51 - /**  
52 - * @return \yii\db\ActiveQuery  
53 - */  
54 - public function getCategories()  
55 - {  
56 - return $this->hasMany(Category::className(), ['category_name_id' => 'category_name_id']);  
57 - }  
58 -  
59 - /**  
60 - * @return \yii\db\ActiveQuery  
61 - */  
62 - public function getCategory()  
63 - {  
64 - return $this->hasOne(Category::className(), ['category_id' => 'category_id']);  
65 - }  
66 -}  
common/modules/product/models/CategoryQuery.php
@@ -23,7 +23,6 @@ class CategoryQuery extends \yii\db\ActiveQuery @@ -23,7 +23,6 @@ class CategoryQuery extends \yii\db\ActiveQuery
23 */ 23 */
24 public function all($db = null) 24 public function all($db = null)
25 { 25 {
26 - $this->with('categoryName');  
27 return parent::all($db); 26 return parent::all($db);
28 } 27 }
29 28
common/modules/product/models/CategorySearch.php
@@ -56,7 +56,7 @@ class CategorySearch extends Category @@ -56,7 +56,7 @@ class CategorySearch extends Category
56 */ 56 */
57 public function search($params) 57 public function search($params)
58 { 58 {
59 - $query = Category::find()->with('categoryName'); 59 + $query = Category::find();
60 60
61 // add conditions that should always apply here 61 // add conditions that should always apply here
62 62
@@ -90,7 +90,6 @@ class CategorySearch extends Category @@ -90,7 +90,6 @@ class CategorySearch extends Category
90 public static function findByAlias($alias) { 90 public static function findByAlias($alias) {
91 /** @var CategoryQuery $query */ 91 /** @var CategoryQuery $query */
92 $query = Category::find() 92 $query = Category::find()
93 - ->with('categoryName')  
94 ->andFilterWhere(['alias' => $alias]); 93 ->andFilterWhere(['alias' => $alias]);
95 if (($model = $query->one()) !== null) { 94 if (($model = $query->one()) !== null) {
96 return $model; 95 return $model;
@@ -102,7 +101,6 @@ class CategorySearch extends Category @@ -102,7 +101,6 @@ class CategorySearch extends Category
102 public static function findByRemoteID($id) { 101 public static function findByRemoteID($id) {
103 /** @var CategoryQuery $query */ 102 /** @var CategoryQuery $query */
104 $query = Category::find() 103 $query = Category::find()
105 - ->with('categoryName')  
106 ->andFilterWhere(['@>', 'remote_id', ArtboxTreeHelper::setArrayField($id)]); 104 ->andFilterWhere(['@>', 'remote_id', ArtboxTreeHelper::setArrayField($id)]);
107 if (($model = $query->one()) !== null) { 105 if (($model = $query->one()) !== null) {
108 return $model; 106 return $model;
common/modules/product/models/Product.php
@@ -218,7 +218,7 @@ class Product extends \yii\db\ActiveRecord @@ -218,7 +218,7 @@ class Product extends \yii\db\ActiveRecord
218 // return $this->getRelations('product_categories'); 218 // return $this->getRelations('product_categories');
219 } 219 }
220 public function getCategoriesWithName() { 220 public function getCategoriesWithName() {
221 - return $this->hasMany(Category::className(), ['category_id' => 'category_id'])->viaTable('product_category', ['product_id' => 'product_id'])->joinWith('categoryNames'); 221 + return $this->hasMany(Category::className(), ['category_id' => 'category_id'])->viaTable('product_category', ['product_id' => 'product_id']);
222 // return $this->getRelations('product_categories'); 222 // return $this->getRelations('product_categories');
223 } 223 }
224 224
common/modules/product/models/ProductSearch.php
@@ -51,7 +51,7 @@ class ProductSearch extends Product @@ -51,7 +51,7 @@ class ProductSearch extends Product
51 { 51 {
52 $query = Product::find(); 52 $query = Product::find();
53 53
54 - $query->joinWith(['brand', 'brand.brandNames', 'categories', 'categories.categoryNames', 'variant']); 54 + $query->joinWith(['brand', 'categories', 'variant']);
55 55
56 $query->groupBy(['product.product_id']); 56 $query->groupBy(['product.product_id']);
57 $query->orderBy('product.product_id', 'DESC'); 57 $query->orderBy('product.product_id', 'DESC');
common/modules/product/models/ProductVariantSearch.php
@@ -87,7 +87,7 @@ class ProductVariantSearch extends ProductVariant @@ -87,7 +87,7 @@ class ProductVariantSearch extends ProductVariant
87 ] 87 ]
88 ]); 88 ]);
89 89
90 - $query->joinWith(['product', 'product.brand.brandNames', 'product.categories', 'product.categories.categoryNames']); 90 + $query->joinWith(['product', 'product.brand', 'product.categories']);
91 91
92 if (isset($this->is_top)) { 92 if (isset($this->is_top)) {
93 $query->andFilterWhere([ 93 $query->andFilterWhere([
common/modules/product/widgets/brandsCarouselWidget.php
@@ -13,7 +13,7 @@ class brandsCarouselWidget extends Widget { @@ -13,7 +13,7 @@ class brandsCarouselWidget extends Widget {
13 } 13 }
14 14
15 public function run() { 15 public function run() {
16 - $brands = Brand::find()->with('brandName')->all(); 16 + $brands = Brand::find()->all();
17 return $this->render('brandsCarousel', [ 17 return $this->render('brandsCarousel', [
18 'brands' => $brands, 18 'brands' => $brands,
19 ]); 19 ]);
common/modules/product/widgets/views/submenu.php
1 <div class="menu_item"> 1 <div class="menu_item">
2 - <?= \yii\helpers\Html::a($rootCategory->categoryName->value, ['catalog/category', 'category' => $rootCategory], ['class' => 'submenu_button '. $rootClass])?> 2 + <?= \yii\helpers\Html::a($rootCategory->name, ['catalog/category', 'category' => $rootCategory], ['class' => 'submenu_button '. $rootClass])?>
3 <div class="submenu"> 3 <div class="submenu">
4 <ul class="categories"> 4 <ul class="categories">
5 <li class="sub_cat"><span>ะŸะพะฟัƒะปัั€ะฝั‹ะต ะบะฐั‚ะตะณะพั€ะธะธ</span> 5 <li class="sub_cat"><span>ะŸะพะฟัƒะปัั€ะฝั‹ะต ะบะฐั‚ะตะณะพั€ะธะธ</span>
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 <?= $_item->imageUrl ? \common\components\artboximage\ArtboxImageHelper::getImage($_item->imageUrl, 'mainmenu') : ''?> 15 <?= $_item->imageUrl ? \common\components\artboximage\ArtboxImageHelper::getImage($_item->imageUrl, 'mainmenu') : ''?>
16 <?php endif?> 16 <?php endif?>
17 </div> 17 </div>
18 - <div class="title"><?= $_item->categoryName->value?></div> 18 + <div class="title"><?= $_item->name?></div>
19 </a></div> 19 </a></div>
20 <?php endforeach?> 20 <?php endforeach?>
21 </div> 21 </div>
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 </li> 24 </li>
25 <?php foreach($items as $item) :?> 25 <?php foreach($items as $item) :?>
26 <li class="sub_cat"> 26 <li class="sub_cat">
27 - <span><?= $item['item']->categoryName->value?></span> 27 + <span><?= $item['item']->name?></span>
28 <?php if(!empty($item['children'])) :?> 28 <?php if(!empty($item['children'])) :?>
29 <div class="sub_cat_content"> 29 <div class="sub_cat_content">
30 <div class="content_items"> 30 <div class="content_items">
@@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
37 <?= $_item['item']->imageUrl ? \common\components\artboximage\ArtboxImageHelper::getImage($_item['item']->imageUrl, 'mainmenu') : ''?> 37 <?= $_item['item']->imageUrl ? \common\components\artboximage\ArtboxImageHelper::getImage($_item['item']->imageUrl, 'mainmenu') : ''?>
38 <?php endif?> 38 <?php endif?>
39 </div> 39 </div>
40 - <div class="title"><?= $_item['item']->categoryName->value?></div> 40 + <div class="title"><?= $_item['item']->name?></div>
41 </a></div> 41 </a></div>
42 <?php endforeach?> 42 <?php endforeach?>
43 </div> 43 </div>
common/modules/rubrication/views/tax-group/_form.php
@@ -26,7 +26,7 @@ use common\components\artboxtree\ArtboxTreeHelper; @@ -26,7 +26,7 @@ use common\components\artboxtree\ArtboxTreeHelper;
26 ]) ?> 26 ]) ?>
27 27
28 <?= $form->field($model, 'group_to_category')->dropDownList( 28 <?= $form->field($model, 'group_to_category')->dropDownList(
29 - ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'categoryName.value'), 29 + ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'name'),
30 [ 30 [
31 'multiple' => true 31 'multiple' => true
32 ] 32 ]
console/controllers/ImportController.php
@@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
3 namespace console\controllers; 3 namespace console\controllers;
4 4
5 use common\modules\product\models\Category; 5 use common\modules\product\models\Category;
6 -use common\modules\product\models\CategoryName;  
7 use common\modules\product\models\Import; 6 use common\modules\product\models\Import;
8 use common\modules\product\models\ProductImage; 7 use common\modules\product\models\ProductImage;
9 use common\modules\product\models\ProductVariantType; 8 use common\modules\product\models\ProductVariantType;
@@ -12,10 +11,8 @@ use common\modules\rubrication\models\TaxOption; @@ -12,10 +11,8 @@ use common\modules\rubrication\models\TaxOption;
12 use common\modules\rubrication\models\TaxValueString; 11 use common\modules\rubrication\models\TaxValueString;
13 use Yii; 12 use Yii;
14 use common\modules\product\models\Brand; 13 use common\modules\product\models\Brand;
15 -use common\modules\product\models\BrandName;  
16 use common\modules\product\models\Product; 14 use common\modules\product\models\Product;
17 use common\modules\product\models\ProductVariant; 15 use common\modules\product\models\ProductVariant;
18 -use common\modules\product\models\RemoteProducts;  
19 use yii\console\Controller; 16 use yii\console\Controller;
20 use yii\helpers\Console; 17 use yii\helpers\Console;
21 18
frontend/controllers/CatalogController.php
@@ -166,7 +166,7 @@ class CatalogController extends \yii\web\Controller @@ -166,7 +166,7 @@ class CatalogController extends \yii\web\Controller
166 public function actionBrands() 166 public function actionBrands()
167 { 167 {
168 $dataProvider = new ActiveDataProvider([ 168 $dataProvider = new ActiveDataProvider([
169 - 'query' => Brand::find()->joinWith('brandName')->orderBy('brand_name.value'), 169 + 'query' => Brand::find()->orderBy('name'),
170 'pagination' => [ 170 'pagination' => [
171 'pageSize' => -1, 171 'pageSize' => -1,
172 ] 172 ]
frontend/models/ProductFrontendSearch.php
@@ -91,7 +91,7 @@ class ProductFrontendSearch extends Product { @@ -91,7 +91,7 @@ class ProductFrontendSearch extends Product {
91 $query = Product::find(); 91 $query = Product::find();
92 } 92 }
93 $query->select(['product.*']); 93 $query->select(['product.*']);
94 - $query->joinWith(['enabledVariants','brand', 'brand.brandName', 'category', 'category.categoryName']); 94 + $query->joinWith(['enabledVariants','brand', 'category']);
95 95
96 $query->groupBy(['product.product_id', 'product_variant.price']); 96 $query->groupBy(['product.product_id', 'product_variant.price']);
97 97
frontend/views/catalog/_product_item.php
@@ -19,8 +19,8 @@ use yii\helpers\Url; @@ -19,8 +19,8 @@ use yii\helpers\Url;
19 'product' => $model->alias 19 'product' => $model->alias
20 ]) ?>"> 20 ]) ?>">
21 <?= \common\components\artboximage\ArtboxImageHelper::getImage($model->enabledVariants[ 0 ]->imageUrl, 'list', [ 21 <?= \common\components\artboximage\ArtboxImageHelper::getImage($model->enabledVariants[ 0 ]->imageUrl, 'list', [
22 - 'alt' => $model->category->categoryName->value . ' ' . $model->fullname,  
23 - 'title' => $model->category->categoryName->value . ' ' . $model->fullname, 22 + 'alt' => $model->category->name . ' ' . $model->fullname,
  23 + 'title' => $model->category->name . ' ' . $model->fullname,
24 'class' => 'selected' 24 'class' => 'selected'
25 ]) ?> 25 ]) ?>
26 </a> 26 </a>