Commit 8d168e89eb24de5e992e90079b0d138f2457ffe1

Authored by Yarik
2 parents b213b850 9111c0e2

Merge remote-tracking branch 'origin/master'

models/Category.php
@@ -291,6 +291,7 @@ @@ -291,6 +291,7 @@
291 'tax_option.id as tax_option_id', 291 'tax_option.id as tax_option_id',
292 'tax_option_lang.alias as option_alias', 292 'tax_option_lang.alias as option_alias',
293 'tax_group_lang.alias as group_alias', 293 'tax_group_lang.alias as group_alias',
  294 + 'tax_group_lang.title as title',
294 'tax_option_lang.value as value', 295 'tax_option_lang.value as value',
295 'tax_option.sort AS tax_option_sort', 296 'tax_option.sort AS tax_option_sort',
296 'tax_group.sort AS tax_group_sort', 297 'tax_group.sort AS tax_group_sort',
models/Product.php
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace artweb\artbox\ecommerce\models; 3 namespace artweb\artbox\ecommerce\models;
4 4
  5 + use artweb\artbox\behaviors\SaveImgBehavior;
5 use artweb\artbox\comment\models\CommentModel; 6 use artweb\artbox\comment\models\CommentModel;
6 use artweb\artbox\comment\models\interfaces\RatingCacheInterface; 7 use artweb\artbox\comment\models\interfaces\RatingCacheInterface;
7 use artweb\artbox\ecommerce\behaviors\DefaultVariantBehavior; 8 use artweb\artbox\ecommerce\behaviors\DefaultVariantBehavior;
@@ -22,6 +23,7 @@ @@ -22,6 +23,7 @@
22 * @property integer $brand_id 23 * @property integer $brand_id
23 * @property integer $id 24 * @property integer $id
24 * @property ProductVideo[] $videos 25 * @property ProductVideo[] $videos
  26 + * @property string $size_image
25 * @property Category $category 27 * @property Category $category
26 * @property Category[] $categories 28 * @property Category[] $categories
27 * @property ProductVariant $variant 29 * @property ProductVariant $variant
@@ -122,7 +124,7 @@ @@ -122,7 +124,7 @@
122 'product_id' => 'id', 124 'product_id' => 'id',
123 ], 125 ],
124 'conditions' => [ 126 'conditions' => [
125 - 'product_image.product_variant_id' => null, 127 + 'product_image.product_variant_id' => NULL,
126 ], 128 ],
127 'model' => ProductImage::className(), 129 'model' => ProductImage::className(),
128 'config' => [ 130 'config' => [
@@ -140,6 +142,15 @@ @@ -140,6 +142,15 @@
140 'cacheRating' => true, 142 'cacheRating' => true,
141 'cacheModelName' => ProductToRating::className(), 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,6 +195,10 @@
184 ], 195 ],
185 'boolean', 196 'boolean',
186 ], 197 ],
  198 + [
  199 + [ 'size_image' ],
  200 + 'string',
  201 + ],
187 ]; 202 ];
188 } 203 }
189 204
@@ -204,6 +219,7 @@ @@ -204,6 +219,7 @@
204 'is_top' => Yii::t('product', 'Is top'), 219 'is_top' => Yii::t('product', 'Is top'),
205 'is_new' => Yii::t('product', 'Is new'), 220 'is_new' => Yii::t('product', 'Is new'),
206 'is_discount' => Yii::t('product', 'Is promo'), 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,20 +161,31 @@
161 * 161 *
162 * @return array 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 /** @var ActiveQuery $query */ 167 /** @var ActiveQuery $query */
  168 +// $query = $category->getRelations('product_categories');
169 $query = $category->getProducts(); 169 $query = $category->getProducts();
170 } else { 170 } else {
171 $query = Product::find(); 171 $query = Product::find();
172 } 172 }
173 $query->joinWith('variant'); 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 return [ 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 \ No newline at end of file 192 \ No newline at end of file
models/TaxGroupSearch.php
@@ -14,6 +14,10 @@ @@ -14,6 +14,10 @@
14 14
15 public $groupName; 15 public $groupName;
16 16
  17 + public $alias;
  18 +
  19 + public $description;
  20 +
17 public function behaviors() 21 public function behaviors()
18 { 22 {
19 $behaviors = parent::behaviors(); 23 $behaviors = parent::behaviors();
@@ -33,6 +37,7 @@ @@ -33,6 +37,7 @@
33 [ 37 [
34 'id', 38 'id',
35 'level', 39 'level',
  40 + 'sort',
36 ], 41 ],
37 'integer', 42 'integer',
38 ], 43 ],
@@ -45,6 +50,8 @@ @@ -45,6 +50,8 @@
45 [ 50 [
46 [ 51 [
47 'groupName', 52 'groupName',
  53 + 'alias',
  54 + 'description',
48 ], 55 ],
49 'safe', 56 'safe',
50 ], 57 ],
@@ -67,7 +74,7 @@ @@ -67,7 +74,7 @@
67 * 74 *
68 * @return ActiveDataProvider 75 * @return ActiveDataProvider
69 */ 76 */
70 - public function search($params, int $level = null) 77 + public function search($params, int $level = NULL)
71 { 78 {
72 $query = TaxGroup::find() 79 $query = TaxGroup::find()
73 ->joinWith('lang'); 80 ->joinWith('lang');
@@ -78,11 +85,20 @@ @@ -78,11 +85,20 @@
78 'sort' => [ 85 'sort' => [
79 'attributes' => [ 86 'attributes' => [
80 'id', 87 'id',
  88 + 'sort',
81 'is_filter', 89 'is_filter',
82 - 'groupName' => [ 90 + 'groupName' => [
83 'asc' => [ 'tax_group_lang.title' => SORT_ASC ], 91 'asc' => [ 'tax_group_lang.title' => SORT_ASC ],
84 'desc' => [ 'tax_group_lang.title' => SORT_DESC ], 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,6 +121,7 @@
105 'id' => $this->id, 121 'id' => $this->id,
106 'is_filter' => $this->is_filter, 122 'is_filter' => $this->is_filter,
107 'level' => $this->level, 123 'level' => $this->level,
  124 + 'sort' => $this->sort,
108 ] 125 ]
109 ) 126 )
110 ->andFilterWhere( 127 ->andFilterWhere(
@@ -113,6 +130,20 @@ @@ -113,6 +130,20 @@
113 'tax_group_lang.title', 130 'tax_group_lang.title',
114 $this->groupName, 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 return $dataProvider; 149 return $dataProvider;
views/manage/_form.php
1 <?php 1 <?php
2 2
  3 + use artweb\artbox\components\artboximage\ArtboxImageHelper;
3 use artweb\artbox\ecommerce\models\ProductVideo; 4 use artweb\artbox\ecommerce\models\ProductVideo;
4 use artweb\artbox\language\widgets\LanguageForm; 5 use artweb\artbox\language\widgets\LanguageForm;
5 use artweb\artbox\ecommerce\models\Brand; 6 use artweb\artbox\ecommerce\models\Brand;
@@ -181,6 +182,33 @@ $(&quot;.dynamicform_wrapper&quot;).on(&quot;limitReached&quot;, function(e, item) { @@ -181,6 +182,33 @@ $(&quot;.dynamicform_wrapper&quot;).on(&quot;limitReached&quot;, 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 <?php if (!empty( $groups )) { 212 <?php if (!empty( $groups )) {
185 foreach ($groups->with('lang') 213 foreach ($groups->with('lang')
186 ->all() as $group) { 214 ->all() as $group) {
views/tax-group/index.php
@@ -41,7 +41,7 @@ @@ -41,7 +41,7 @@
41 'filterModel' => $searchModel, 41 'filterModel' => $searchModel,
42 'columns' => [ 42 'columns' => [
43 [ 'class' => 'yii\grid\SerialColumn' ], 43 [ 'class' => 'yii\grid\SerialColumn' ],
44 - 'id', 44 + 'sort',
45 [ 45 [
46 'attribute' => 'is_filter', 46 'attribute' => 'is_filter',
47 'format' => 'boolean', 47 'format' => 'boolean',
@@ -52,22 +52,12 @@ @@ -52,22 +52,12 @@
52 'value' => 'lang.title', 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 'class' => 'yii\grid\ActionColumn', 63 'class' => 'yii\grid\ActionColumn',