Commit 8d168e89eb24de5e992e90079b0d138f2457ffe1
Merge remote-tracking branch 'origin/master'
Showing
6 changed files
with
102 additions
and
25 deletions
Show diff stats
models/Category.php
... | ... | @@ -291,6 +291,7 @@ |
291 | 291 | 'tax_option.id as tax_option_id', |
292 | 292 | 'tax_option_lang.alias as option_alias', |
293 | 293 | 'tax_group_lang.alias as group_alias', |
294 | + 'tax_group_lang.title as title', | |
294 | 295 | 'tax_option_lang.value as value', |
295 | 296 | 'tax_option.sort AS tax_option_sort', |
296 | 297 | 'tax_group.sort AS tax_group_sort', | ... | ... |
models/Product.php
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | |
3 | 3 | namespace artweb\artbox\ecommerce\models; |
4 | 4 | |
5 | + use artweb\artbox\behaviors\SaveImgBehavior; | |
5 | 6 | use artweb\artbox\comment\models\CommentModel; |
6 | 7 | use artweb\artbox\comment\models\interfaces\RatingCacheInterface; |
7 | 8 | use artweb\artbox\ecommerce\behaviors\DefaultVariantBehavior; |
... | ... | @@ -22,6 +23,7 @@ |
22 | 23 | * @property integer $brand_id |
23 | 24 | * @property integer $id |
24 | 25 | * @property ProductVideo[] $videos |
26 | + * @property string $size_image | |
25 | 27 | * @property Category $category |
26 | 28 | * @property Category[] $categories |
27 | 29 | * @property ProductVariant $variant |
... | ... | @@ -122,7 +124,7 @@ |
122 | 124 | 'product_id' => 'id', |
123 | 125 | ], |
124 | 126 | 'conditions' => [ |
125 | - 'product_image.product_variant_id' => null, | |
127 | + 'product_image.product_variant_id' => NULL, | |
126 | 128 | ], |
127 | 129 | 'model' => ProductImage::className(), |
128 | 130 | 'config' => [ |
... | ... | @@ -140,6 +142,15 @@ |
140 | 142 | 'cacheRating' => true, |
141 | 143 | 'cacheModelName' => ProductToRating::className(), |
142 | 144 | ], |
145 | + 'size_image' => [ | |
146 | + 'class' => SaveImgBehavior::className(), | |
147 | + 'fields' => [ | |
148 | + [ | |
149 | + 'name' => 'size_image', | |
150 | + 'directory' => 'products', | |
151 | + ], | |
152 | + ], | |
153 | + ], | |
143 | 154 | ]; |
144 | 155 | } |
145 | 156 | |
... | ... | @@ -184,6 +195,10 @@ |
184 | 195 | ], |
185 | 196 | 'boolean', |
186 | 197 | ], |
198 | + [ | |
199 | + [ 'size_image' ], | |
200 | + 'string', | |
201 | + ], | |
187 | 202 | ]; |
188 | 203 | } |
189 | 204 | |
... | ... | @@ -204,6 +219,7 @@ |
204 | 219 | 'is_top' => Yii::t('product', 'Is top'), |
205 | 220 | 'is_new' => Yii::t('product', 'Is new'), |
206 | 221 | 'is_discount' => Yii::t('product', 'Is promo'), |
222 | + 'size_image' => Yii::t('product', 'Sizes table'), | |
207 | 223 | ]; |
208 | 224 | } |
209 | 225 | ... | ... |
models/ProductFrontendSearch.php
... | ... | @@ -161,20 +161,31 @@ |
161 | 161 | * |
162 | 162 | * @return array |
163 | 163 | */ |
164 | - | |
165 | - public function priceLimits($category = null) | |
166 | - { | |
167 | - if (!empty( $category )) { | |
164 | + | |
165 | + public function priceLimits($category = null, $params = []) { | |
166 | + if (!empty($category)) { | |
168 | 167 | /** @var ActiveQuery $query */ |
168 | +// $query = $category->getRelations('product_categories'); | |
169 | 169 | $query = $category->getProducts(); |
170 | 170 | } else { |
171 | 171 | $query = Product::find(); |
172 | 172 | } |
173 | 173 | $query->joinWith('variant'); |
174 | - | |
174 | + | |
175 | + // Price filter fix | |
176 | + unset($params['prices']); | |
177 | + | |
178 | + FilterHelper::setQueryParams($query, $params); | |
179 | + $query->andWhere( | |
180 | + [ | |
181 | + '>=', | |
182 | + ProductVariant::tableName() . '.stock', | |
183 | + 1, | |
184 | + ] | |
185 | + ); | |
175 | 186 | return [ |
176 | - 'min' => $query->min(ProductVariant::tableName() . '.price'), | |
177 | - 'max' => $query->max(ProductVariant::tableName() . '.price'), | |
187 | + 'min' => $query->min(ProductVariant::tableName() .'.price'), | |
188 | + 'max' => $query->max(ProductVariant::tableName() .'.price'), | |
178 | 189 | ]; |
179 | 190 | } |
180 | 191 | } |
181 | 192 | \ No newline at end of file | ... | ... |
models/TaxGroupSearch.php
... | ... | @@ -14,6 +14,10 @@ |
14 | 14 | |
15 | 15 | public $groupName; |
16 | 16 | |
17 | + public $alias; | |
18 | + | |
19 | + public $description; | |
20 | + | |
17 | 21 | public function behaviors() |
18 | 22 | { |
19 | 23 | $behaviors = parent::behaviors(); |
... | ... | @@ -33,6 +37,7 @@ |
33 | 37 | [ |
34 | 38 | 'id', |
35 | 39 | 'level', |
40 | + 'sort', | |
36 | 41 | ], |
37 | 42 | 'integer', |
38 | 43 | ], |
... | ... | @@ -45,6 +50,8 @@ |
45 | 50 | [ |
46 | 51 | [ |
47 | 52 | 'groupName', |
53 | + 'alias', | |
54 | + 'description', | |
48 | 55 | ], |
49 | 56 | 'safe', |
50 | 57 | ], |
... | ... | @@ -67,7 +74,7 @@ |
67 | 74 | * |
68 | 75 | * @return ActiveDataProvider |
69 | 76 | */ |
70 | - public function search($params, int $level = null) | |
77 | + public function search($params, int $level = NULL) | |
71 | 78 | { |
72 | 79 | $query = TaxGroup::find() |
73 | 80 | ->joinWith('lang'); |
... | ... | @@ -78,11 +85,20 @@ |
78 | 85 | 'sort' => [ |
79 | 86 | 'attributes' => [ |
80 | 87 | 'id', |
88 | + 'sort', | |
81 | 89 | 'is_filter', |
82 | - 'groupName' => [ | |
90 | + 'groupName' => [ | |
83 | 91 | 'asc' => [ 'tax_group_lang.title' => SORT_ASC ], |
84 | 92 | 'desc' => [ 'tax_group_lang.title' => SORT_DESC ], |
85 | 93 | ], |
94 | + 'alias' => [ | |
95 | + 'asc' => [ 'tax_group_lang.alias' => SORT_ASC ], | |
96 | + 'desc' => [ 'tax_group_lang.alias' => SORT_DESC ], | |
97 | + ], | |
98 | + 'description' => [ | |
99 | + 'asc' => [ 'tax_group_lang.description' => SORT_ASC ], | |
100 | + 'desc' => [ 'tax_group_lang.description' => SORT_DESC ], | |
101 | + ], | |
86 | 102 | ], |
87 | 103 | ], |
88 | 104 | ] |
... | ... | @@ -105,6 +121,7 @@ |
105 | 121 | 'id' => $this->id, |
106 | 122 | 'is_filter' => $this->is_filter, |
107 | 123 | 'level' => $this->level, |
124 | + 'sort' => $this->sort, | |
108 | 125 | ] |
109 | 126 | ) |
110 | 127 | ->andFilterWhere( |
... | ... | @@ -113,6 +130,20 @@ |
113 | 130 | 'tax_group_lang.title', |
114 | 131 | $this->groupName, |
115 | 132 | ] |
133 | + ) | |
134 | + ->andFilterWhere( | |
135 | + [ | |
136 | + 'ilike', | |
137 | + 'tax_group_lang.alias', | |
138 | + $this->alias, | |
139 | + ] | |
140 | + ) | |
141 | + ->andFilterWhere( | |
142 | + [ | |
143 | + 'ilike', | |
144 | + 'tax_group_lang.description', | |
145 | + $this->description, | |
146 | + ] | |
116 | 147 | ); |
117 | 148 | |
118 | 149 | return $dataProvider; | ... | ... |
views/manage/_form.php
1 | 1 | <?php |
2 | 2 | |
3 | + use artweb\artbox\components\artboximage\ArtboxImageHelper; | |
3 | 4 | use artweb\artbox\ecommerce\models\ProductVideo; |
4 | 5 | use artweb\artbox\language\widgets\LanguageForm; |
5 | 6 | use artweb\artbox\ecommerce\models\Brand; |
... | ... | @@ -181,6 +182,33 @@ $(".dynamicform_wrapper").on("limitReached", function(e, item) { |
181 | 182 | ] |
182 | 183 | ); ?> |
183 | 184 | |
185 | + <?= $form->field($model, 'size_image') | |
186 | + ->widget( | |
187 | + \kartik\file\FileInput::className(), | |
188 | + [ | |
189 | + 'language' => 'ru', | |
190 | + 'options' => [ | |
191 | + 'accept' => 'image/*', | |
192 | + 'multiple' => false, | |
193 | + ], | |
194 | + 'pluginOptions' => [ | |
195 | + 'allowedFileExtensions' => [ | |
196 | + 'jpg', | |
197 | + 'gif', | |
198 | + 'png', | |
199 | + ], | |
200 | + 'initialPreview' => !empty( $model->getBehavior('size_image')->imageUrl ) ? ArtboxImageHelper::getImage( | |
201 | + $model->getBehavior('size_image')->imageUrl, | |
202 | + 'list' | |
203 | + ) : '', | |
204 | + 'overwriteInitial' => true, | |
205 | + 'showRemove' => false, | |
206 | + 'showUpload' => false, | |
207 | + 'previewFileType' => 'image', | |
208 | + ], | |
209 | + ] | |
210 | + ); ?> | |
211 | + | |
184 | 212 | <?php if (!empty( $groups )) { |
185 | 213 | foreach ($groups->with('lang') |
186 | 214 | ->all() as $group) { | ... | ... |
views/tax-group/index.php
... | ... | @@ -41,7 +41,7 @@ |
41 | 41 | 'filterModel' => $searchModel, |
42 | 42 | 'columns' => [ |
43 | 43 | [ 'class' => 'yii\grid\SerialColumn' ], |
44 | - 'id', | |
44 | + 'sort', | |
45 | 45 | [ |
46 | 46 | 'attribute' => 'is_filter', |
47 | 47 | 'format' => 'boolean', |
... | ... | @@ -52,22 +52,12 @@ |
52 | 52 | 'value' => 'lang.title', |
53 | 53 | ], |
54 | 54 | [ |
55 | - 'label' => \Yii::t('rubrication', 'Options count'), | |
56 | - 'value' => function ($model) { | |
57 | - /** | |
58 | - * @var TaxGroup $model | |
59 | - */ | |
60 | - return count($model->options); | |
61 | - }, | |
55 | + 'attribute' => 'alias', | |
56 | + 'value' => 'lang.alias' | |
62 | 57 | ], |
63 | 58 | [ |
64 | - 'label' => \Yii::t('rubrication', 'Categories count'), | |
65 | - 'value' => function ($model) { | |
66 | - /** | |
67 | - * @var TaxGroup $model | |
68 | - */ | |
69 | - return count($model->categories); | |
70 | - }, | |
59 | + 'attribute' => 'description', | |
60 | + 'value' => 'lang.description' | |
71 | 61 | ], |
72 | 62 | [ |
73 | 63 | 'class' => 'yii\grid\ActionColumn', | ... | ... |