Commit 871a734907eeacc25c625fbcf0fdabcab2905de8
1 parent
52aea36a
big commti
Showing
22 changed files
with
47 additions
and
270 deletions
Show diff stats
backend/controllers/CategoryController.php
... | ... | @@ -97,7 +97,7 @@ class CategoryController extends Controller |
97 | 97 | } |
98 | 98 | return $this->render('create', [ |
99 | 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 | 125 | } else { |
126 | 126 | return $this->render('update', [ |
127 | 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 | 2 | namespace backend\controllers; |
3 | 3 | use developeruz\db_rbac\behaviors\AccessBehavior; |
4 | 4 | use common\modules\product\models\Brand; |
5 | -use common\modules\product\models\BrandName; | |
6 | 5 | use common\modules\product\models\Category; |
7 | -use common\modules\product\models\CategoryName; | |
8 | 6 | use common\modules\product\models\Product; |
9 | 7 | use common\modules\product\models\ProductVariant; |
10 | 8 | use common\modules\product\models\ProductVariantType; |
... | ... | @@ -199,7 +197,7 @@ class SiteController extends Controller |
199 | 197 | } |
200 | 198 | |
201 | 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 | 201 | $_product->categories = [$category->category_id]; |
204 | 202 | } else { |
205 | 203 | // Create category |
... | ... | @@ -211,7 +209,7 @@ class SiteController extends Controller |
211 | 209 | |
212 | 210 | // ===== Set brand ==== |
213 | 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 | 213 | $_product->brand_id = $brand->brand_id; |
216 | 214 | } else { |
217 | 215 | // Create brand | ... | ... |
common/modules/product/controllers/ManageController.php
... | ... | @@ -8,7 +8,6 @@ use common\modules\product\models\Export; |
8 | 8 | use common\modules\product\models\Import; |
9 | 9 | use common\modules\product\models\ProductImage; |
10 | 10 | use common\modules\product\models\ProductVariant; |
11 | -use common\modules\product\models\RemoteProductsSearch; | |
12 | 11 | use Yii; |
13 | 12 | use common\modules\product\models\Product; |
14 | 13 | use common\modules\product\models\ProductSearch; |
... | ... | @@ -16,8 +15,6 @@ use yii\web\Controller; |
16 | 15 | use yii\web\NotFoundHttpException; |
17 | 16 | use yii\filters\VerbFilter; |
18 | 17 | use common\modules\product\models\Brand; |
19 | -use common\modules\product\models\BrandName; | |
20 | -use common\modules\product\models\RemoteProducts; | |
21 | 18 | use yii\web\UploadedFile; |
22 | 19 | |
23 | 20 | /** | ... | ... |
common/modules/product/helpers/FilterHelper.php
... | ... | @@ -2,9 +2,7 @@ |
2 | 2 | |
3 | 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 | 6 | use common\modules\rubrication\models\TaxGroup; |
9 | 7 | use yii\base\Object; |
10 | 8 | use Yii; | ... | ... |
common/modules/product/helpers/ProductHelper.php
... | ... | @@ -6,8 +6,6 @@ |
6 | 6 | use common\modules\product\models\Category; |
7 | 7 | use common\modules\product\models\Product; |
8 | 8 | use common\modules\product\models\ProductVariant; |
9 | - use common\modules\product\models\BrandName; | |
10 | - use common\modules\product\models\CategoryName; | |
11 | 9 | use yii\base\Object; |
12 | 10 | use Yii; |
13 | 11 | use yii\db\ActiveQuery; |
... | ... | @@ -202,12 +200,12 @@ |
202 | 200 | ]); |
203 | 201 | $query->orFilterWhere([ |
204 | 202 | 'ilike', |
205 | - BrandName::tableName() . '.value', | |
203 | + Brand::tableName() . '.name', | |
206 | 204 | $keyword, |
207 | 205 | ]); |
208 | 206 | $query->orFilterWhere([ |
209 | 207 | 'ilike', |
210 | - CategoryName::tableName() . '.value', | |
208 | + Category::tableName() . '.name', | |
211 | 209 | $keyword, |
212 | 210 | ]); |
213 | 211 | $query->orFilterWhere([ | ... | ... |
common/modules/product/models/Brand.php
... | ... | @@ -19,6 +19,7 @@ use Yii; |
19 | 19 | * @property string $meta_desc |
20 | 20 | * @property string $meta_robots |
21 | 21 | * @property string $seo_text |
22 | + * @property string $name | |
22 | 23 | * |
23 | 24 | * @property BrandName $brandName |
24 | 25 | * @property BrandName[] $brandNames |
... | ... | @@ -30,26 +31,6 @@ class Brand extends \yii\db\ActiveRecord |
30 | 31 | |
31 | 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 | 35 | * @inheritdoc |
55 | 36 | */ |
... | ... | @@ -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 | 81 | * @return \yii\db\ActiveQuery |
... | ... | @@ -118,10 +85,6 @@ class Brand extends \yii\db\ActiveRecord |
118 | 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 | 88 | public function getImageFile() { |
126 | 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 | 81 | ->andFilterWhere(['ilike', 'meta_robots', $this->meta_robots]) |
82 | 82 | ->andFilterWhere(['ilike', 'seo_text', $this->seo_text]); |
83 | 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 | 87 | $query->orderBy('brand_id', 'asc'); |
... | ... | @@ -110,8 +109,7 @@ class BrandSearch extends Brand |
110 | 109 | Brand::tableName() .'.*' |
111 | 110 | ]) |
112 | 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 | 115 | // $queryCount = Product::find() |
... | ... | @@ -157,7 +155,6 @@ class BrandSearch extends Brand |
157 | 155 | public static function findByAlias($alias) { |
158 | 156 | /** @var CategoryQuery $query */ |
159 | 157 | $query = Brand::find() |
160 | - ->with('brandName') | |
161 | 158 | ->andFilterWhere(['alias' => $alias]); |
162 | 159 | if (($model = $query->one()) !== null) { |
163 | 160 | return $model; | ... | ... |
common/modules/product/models/Category.php
... | ... | @@ -2,13 +2,13 @@ |
2 | 2 | |
3 | 3 | namespace common\modules\product\models; |
4 | 4 | |
5 | -use common\behaviors\RuSlug; | |
5 | + | |
6 | 6 | use common\components\artboxtree\ArtboxTreeBehavior; |
7 | 7 | use common\components\artboxtree\ArtboxTreeHelper; |
8 | -use common\modules\rubrication\behaviors\ArtboxSynonymBehavior; | |
8 | + | |
9 | 9 | use common\modules\rubrication\models\TaxGroup; |
10 | 10 | use Yii; |
11 | -use yii\base\ErrorException; | |
11 | + | |
12 | 12 | use yii\db\Query; |
13 | 13 | |
14 | 14 | /** |
... | ... | @@ -28,6 +28,7 @@ use yii\db\Query; |
28 | 28 | * @property integer $product_unit_id |
29 | 29 | * @property string $alias |
30 | 30 | * @property boolean $populary |
31 | + * @property boolean $name | |
31 | 32 | * |
32 | 33 | * @property CategoryName $categoryName |
33 | 34 | * @property Product[] $products |
... | ... | @@ -46,21 +47,7 @@ class Category extends \yii\db\ActiveRecord |
46 | 47 | 'class' => ArtboxTreeBehavior::className(), |
47 | 48 | 'keyNameGroup' => null, |
48 | 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 | 74 | [['alias', 'name'], 'string', 'max' => 250], |
88 | 75 | [['populary'], 'boolean'], |
89 | 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 | 77 | [['imageUpload'], 'safe'], |
92 | 78 | [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], |
93 | 79 | ]; |
... | ... | @@ -137,13 +123,6 @@ class Category extends \yii\db\ActiveRecord |
137 | 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 | 128 | * @return \yii\db\ActiveQuery |
... | ... | @@ -153,10 +132,6 @@ class Category extends \yii\db\ActiveRecord |
153 | 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 | 136 | public function getTaxGroupsByLevel($level) |
162 | 137 | { |
... | ... | @@ -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 | 158 | public function getImageFile() { |
190 | 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 | 185 | } |
217 | 186 | } |
218 | 187 | ProductCategory::deleteAll(['category_id' => $this->category_id]); |
219 | - CategoryName::deleteAll(['category_id' => $this->category_id]); | |
220 | 188 | return true; |
221 | 189 | } |
222 | - | |
223 | 190 | public function getActiveFilters() { |
224 | 191 | $query1 = (new Query()) |
225 | 192 | ->distinct() |
226 | 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 | 196 | ->from('tax_option') |
237 | 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 | 202 | ->innerJoin('tax_value_string', 'tax_value_string.tax_option_id = tax_option.tax_option_id') |
243 | 203 | ->where(['product_category.category_id' => $this->category_id, 'tax_group.is_filter' => TRUE]) |
244 | 204 | ->andWhere(['!=', 'product_variant.stock', 0]); |
245 | - | |
205 | + | |
246 | 206 | $query2 = (new Query()) |
247 | 207 | ->distinct() |
248 | 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 | 211 | ->from('tax_option') |
259 | 212 | ->innerJoin('product_option', 'tax_option.tax_option_id = product_option.option_id') |
... | ... | @@ -265,9 +218,20 @@ class Category extends \yii\db\ActiveRecord |
265 | 218 | ->where(['product_category.category_id' => $this->category_id, 'tax_group.is_filter' => TRUE]) |
266 | 219 | ->andWhere(['!=', 'product_variant.stock', 0]); |
267 | 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 | 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
common/modules/product/models/CategorySearch.php
... | ... | @@ -56,7 +56,7 @@ class CategorySearch extends Category |
56 | 56 | */ |
57 | 57 | public function search($params) |
58 | 58 | { |
59 | - $query = Category::find()->with('categoryName'); | |
59 | + $query = Category::find(); | |
60 | 60 | |
61 | 61 | // add conditions that should always apply here |
62 | 62 | |
... | ... | @@ -90,7 +90,6 @@ class CategorySearch extends Category |
90 | 90 | public static function findByAlias($alias) { |
91 | 91 | /** @var CategoryQuery $query */ |
92 | 92 | $query = Category::find() |
93 | - ->with('categoryName') | |
94 | 93 | ->andFilterWhere(['alias' => $alias]); |
95 | 94 | if (($model = $query->one()) !== null) { |
96 | 95 | return $model; |
... | ... | @@ -102,7 +101,6 @@ class CategorySearch extends Category |
102 | 101 | public static function findByRemoteID($id) { |
103 | 102 | /** @var CategoryQuery $query */ |
104 | 103 | $query = Category::find() |
105 | - ->with('categoryName') | |
106 | 104 | ->andFilterWhere(['@>', 'remote_id', ArtboxTreeHelper::setArrayField($id)]); |
107 | 105 | if (($model = $query->one()) !== null) { |
108 | 106 | return $model; | ... | ... |
common/modules/product/models/Product.php
... | ... | @@ -218,7 +218,7 @@ class Product extends \yii\db\ActiveRecord |
218 | 218 | // return $this->getRelations('product_categories'); |
219 | 219 | } |
220 | 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 | 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 | 51 | { |
52 | 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 | 56 | $query->groupBy(['product.product_id']); |
57 | 57 | $query->orderBy('product.product_id', 'DESC'); | ... | ... |
common/modules/product/models/ProductVariantSearch.php
... | ... | @@ -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 | 92 | if (isset($this->is_top)) { |
93 | 93 | $query->andFilterWhere([ | ... | ... |
common/modules/product/widgets/brandsCarouselWidget.php
common/modules/product/widgets/views/submenu.php
1 | 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 | 3 | <div class="submenu"> |
4 | 4 | <ul class="categories"> |
5 | 5 | <li class="sub_cat"><span>ะะพะฟัะปััะฝัะต ะบะฐัะตะณะพัะธะธ</span> |
... | ... | @@ -15,7 +15,7 @@ |
15 | 15 | <?= $_item->imageUrl ? \common\components\artboximage\ArtboxImageHelper::getImage($_item->imageUrl, 'mainmenu') : ''?> |
16 | 16 | <?php endif?> |
17 | 17 | </div> |
18 | - <div class="title"><?= $_item->categoryName->value?></div> | |
18 | + <div class="title"><?= $_item->name?></div> | |
19 | 19 | </a></div> |
20 | 20 | <?php endforeach?> |
21 | 21 | </div> |
... | ... | @@ -24,7 +24,7 @@ |
24 | 24 | </li> |
25 | 25 | <?php foreach($items as $item) :?> |
26 | 26 | <li class="sub_cat"> |
27 | - <span><?= $item['item']->categoryName->value?></span> | |
27 | + <span><?= $item['item']->name?></span> | |
28 | 28 | <?php if(!empty($item['children'])) :?> |
29 | 29 | <div class="sub_cat_content"> |
30 | 30 | <div class="content_items"> |
... | ... | @@ -37,7 +37,7 @@ |
37 | 37 | <?= $_item['item']->imageUrl ? \common\components\artboximage\ArtboxImageHelper::getImage($_item['item']->imageUrl, 'mainmenu') : ''?> |
38 | 38 | <?php endif?> |
39 | 39 | </div> |
40 | - <div class="title"><?= $_item['item']->categoryName->value?></div> | |
40 | + <div class="title"><?= $_item['item']->name?></div> | |
41 | 41 | </a></div> |
42 | 42 | <?php endforeach?> |
43 | 43 | </div> | ... | ... |
common/modules/rubrication/views/tax-group/_form.php
... | ... | @@ -26,7 +26,7 @@ use common\components\artboxtree\ArtboxTreeHelper; |
26 | 26 | ]) ?> |
27 | 27 | |
28 | 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 | 31 | 'multiple' => true |
32 | 32 | ] | ... | ... |
console/controllers/ImportController.php
... | ... | @@ -3,7 +3,6 @@ |
3 | 3 | namespace console\controllers; |
4 | 4 | |
5 | 5 | use common\modules\product\models\Category; |
6 | -use common\modules\product\models\CategoryName; | |
7 | 6 | use common\modules\product\models\Import; |
8 | 7 | use common\modules\product\models\ProductImage; |
9 | 8 | use common\modules\product\models\ProductVariantType; |
... | ... | @@ -12,10 +11,8 @@ use common\modules\rubrication\models\TaxOption; |
12 | 11 | use common\modules\rubrication\models\TaxValueString; |
13 | 12 | use Yii; |
14 | 13 | use common\modules\product\models\Brand; |
15 | -use common\modules\product\models\BrandName; | |
16 | 14 | use common\modules\product\models\Product; |
17 | 15 | use common\modules\product\models\ProductVariant; |
18 | -use common\modules\product\models\RemoteProducts; | |
19 | 16 | use yii\console\Controller; |
20 | 17 | use yii\helpers\Console; |
21 | 18 | ... | ... |
frontend/controllers/CatalogController.php
... | ... | @@ -166,7 +166,7 @@ class CatalogController extends \yii\web\Controller |
166 | 166 | public function actionBrands() |
167 | 167 | { |
168 | 168 | $dataProvider = new ActiveDataProvider([ |
169 | - 'query' => Brand::find()->joinWith('brandName')->orderBy('brand_name.value'), | |
169 | + 'query' => Brand::find()->orderBy('name'), | |
170 | 170 | 'pagination' => [ |
171 | 171 | 'pageSize' => -1, |
172 | 172 | ] | ... | ... |
frontend/models/ProductFrontendSearch.php
... | ... | @@ -91,7 +91,7 @@ class ProductFrontendSearch extends Product { |
91 | 91 | $query = Product::find(); |
92 | 92 | } |
93 | 93 | $query->select(['product.*']); |
94 | - $query->joinWith(['enabledVariants','brand', 'brand.brandName', 'category', 'category.categoryName']); | |
94 | + $query->joinWith(['enabledVariants','brand', 'category']); | |
95 | 95 | |
96 | 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 | 19 | 'product' => $model->alias |
20 | 20 | ]) ?>"> |
21 | 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 | 24 | 'class' => 'selected' |
25 | 25 | ]) ?> |
26 | 26 | </a> | ... | ... |