Commit d75b9d344d988e4bf57f845c52e35daaf0db6ed5

Authored by Administrator
1 parent 00067cef

add variantSku

Showing 2 changed files with 8 additions and 5 deletions   Show diff stats
models/Product.php
@@ -101,6 +101,9 @@ @@ -101,6 +101,9 @@
101 */ 101 */
102 class Product extends ActiveRecord 102 class Product extends ActiveRecord
103 { 103 {
  104 +
  105 + public $min;
  106 + public $max;
104 107
105 public $imagesUpload = []; 108 public $imagesUpload = [];
106 109
models/ProductFrontendSearch.php
@@ -12,7 +12,8 @@ @@ -12,7 +12,8 @@
12 12
13 use artweb\artbox\ecommerce\models\Product; 13 use artweb\artbox\ecommerce\models\Product;
14 use artweb\artbox\ecommerce\models\ProductVariant; 14 use artweb\artbox\ecommerce\models\ProductVariant;
15 - 15 + use yii\helpers\ArrayHelper;
  16 +
16 class ProductFrontendSearch extends Product 17 class ProductFrontendSearch extends Product
17 { 18 {
18 19
@@ -196,6 +197,8 @@ @@ -196,6 +197,8 @@
196 } else { 197 } else {
197 $query = Product::find(); 198 $query = Product::find();
198 } 199 }
  200 +
  201 + $query->select(['MAX('.ProductVariant::tableName() . '.price) as max', 'MIN('.ProductVariant::tableName() . '.price) as min']);
199 $query->joinWith('variant'); 202 $query->joinWith('variant');
200 203
201 // Price filter fix 204 // Price filter fix
@@ -209,9 +212,6 @@ @@ -209,9 +212,6 @@
209 1, 212 1,
210 ] 213 ]
211 ); 214 );
212 - return [  
213 - 'min' => $query->min(ProductVariant::tableName() . '.price'),  
214 - 'max' => $query->max(ProductVariant::tableName() . '.price'),  
215 - ]; 215 + return $query->one();
216 } 216 }
217 } 217 }
218 \ No newline at end of file 218 \ No newline at end of file