diff --git a/common/modules/product/helpers/ProductHelper.php b/common/modules/product/helpers/ProductHelper.php index 8e20a9d..c3edbc7 100755 --- a/common/modules/product/helpers/ProductHelper.php +++ b/common/modules/product/helpers/ProductHelper.php @@ -186,7 +186,7 @@ * @param $params * @param bool $setPriceLimits */ - public static function _setQueryParams(&$query, $params, $setPriceLimits = true) + public static function _setQueryParams(&$query, $params) { if(!empty( $params[ 'keywords' ] )) { if(!is_array($params[ 'keywords' ])) { diff --git a/frontend/controllers/CatalogController.php b/frontend/controllers/CatalogController.php index 1e21f05..f1440e3 100755 --- a/frontend/controllers/CatalogController.php +++ b/frontend/controllers/CatalogController.php @@ -118,8 +118,7 @@ class CatalogController extends \yii\web\Controller $groups = $category->getActiveFilters(); $groups = ArrayHelper::index($groups, null, 'name'); - - $priceLimits = $productModel->priceLimits($productProvider->query); + $priceLimits = $productModel->priceLimits($category, $params); /* * Greedy search for comments and rating diff --git a/frontend/models/ProductFrontendSearch.php b/frontend/models/ProductFrontendSearch.php index 7793ce7..2188630 100755 --- a/frontend/models/ProductFrontendSearch.php +++ b/frontend/models/ProductFrontendSearch.php @@ -4,10 +4,6 @@ namespace frontend\models; use common\modules\product\helpers\ProductHelper; use common\modules\product\models\Category; -use common\modules\product\models\ProductCategory; -use common\modules\product\models\ProductOption; -use common\modules\rubrication\models\TaxGroup; -use common\modules\rubrication\models\TaxOption; use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; @@ -15,6 +11,7 @@ use yii\db\ActiveQuery; use common\modules\product\models\Product; use common\modules\product\models\ProductVariant; +use yii\helpers\ArrayHelper; class ProductFrontendSearch extends Product { @@ -106,7 +103,26 @@ class ProductFrontendSearch extends Product { } - public function priceLimits($query) { + /** + * @param Category|null $category + * @param array $params + * @return array + */ + + public function priceLimits($category = null, $params = []) { + if (!empty($category)) { + /** @var ActiveQuery $query */ + $query = $category->getProducts(); + } else { + $query = Product::find(); + } + $query->joinWith('variant'); + + // Price filter fix + unset($params['prices']); + + ProductHelper::_setQueryParams($query, $params, false); + return [ 'min' => $query->min(ProductVariant::tableName() .'.price'), -- libgit2 0.21.4