Commit 1504a699dbd9049dee2916fd3f9afe3f9f6040a5

Authored by Administrator
1 parent db2894a2

big commti

common/modules/product/helpers/ProductHelper.php
... ... @@ -186,7 +186,7 @@
186 186 * @param $params
187 187 * @param bool $setPriceLimits
188 188 */
189   - public static function _setQueryParams(&$query, $params, $setPriceLimits = true)
  189 + public static function _setQueryParams(&$query, $params)
190 190 {
191 191 if(!empty( $params[ 'keywords' ] )) {
192 192 if(!is_array($params[ 'keywords' ])) {
... ...
frontend/controllers/CatalogController.php
... ... @@ -118,8 +118,7 @@ class CatalogController extends \yii\web\Controller
118 118  
119 119 $groups = $category->getActiveFilters();
120 120 $groups = ArrayHelper::index($groups, null, 'name');
121   -
122   - $priceLimits = $productModel->priceLimits($productProvider->query);
  121 + $priceLimits = $productModel->priceLimits($category, $params);
123 122  
124 123 /*
125 124 * Greedy search for comments and rating
... ...
frontend/models/ProductFrontendSearch.php
... ... @@ -4,10 +4,6 @@ namespace frontend\models;
4 4  
5 5 use common\modules\product\helpers\ProductHelper;
6 6 use common\modules\product\models\Category;
7   -use common\modules\product\models\ProductCategory;
8   -use common\modules\product\models\ProductOption;
9   -use common\modules\rubrication\models\TaxGroup;
10   -use common\modules\rubrication\models\TaxOption;
11 7 use Yii;
12 8 use yii\base\Model;
13 9 use yii\data\ActiveDataProvider;
... ... @@ -15,6 +11,7 @@ use yii\db\ActiveQuery;
15 11  
16 12 use common\modules\product\models\Product;
17 13 use common\modules\product\models\ProductVariant;
  14 +use yii\helpers\ArrayHelper;
18 15  
19 16 class ProductFrontendSearch extends Product {
20 17  
... ... @@ -106,7 +103,26 @@ class ProductFrontendSearch extends Product {
106 103 }
107 104  
108 105  
109   - public function priceLimits($query) {
  106 + /**
  107 + * @param Category|null $category
  108 + * @param array $params
  109 + * @return array
  110 + */
  111 +
  112 + public function priceLimits($category = null, $params = []) {
  113 + if (!empty($category)) {
  114 + /** @var ActiveQuery $query */
  115 + $query = $category->getProducts();
  116 + } else {
  117 + $query = Product::find();
  118 + }
  119 + $query->joinWith('variant');
  120 +
  121 + // Price filter fix
  122 + unset($params['prices']);
  123 +
  124 + ProductHelper::_setQueryParams($query, $params, false);
  125 +
110 126  
111 127 return [
112 128 'min' => $query->min(ProductVariant::tableName() .'.price'),
... ...