From 93015018a2358aebbc4a5677f1055b8dfc5f06bf Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 17 Nov 2016 16:10:21 +0200 Subject: [PATCH] full commit --- models/ProductFrontendSearch.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/models/ProductFrontendSearch.php b/models/ProductFrontendSearch.php index 0abd297..030ec68 100755 --- a/models/ProductFrontendSearch.php +++ b/models/ProductFrontendSearch.php @@ -161,20 +161,31 @@ * * @return array */ - - public function priceLimits($category = null) - { - if (!empty( $category )) { + + public function priceLimits($category = null, $params = []) { + if (!empty($category)) { /** @var ActiveQuery $query */ +// $query = $category->getRelations('product_categories'); $query = $category->getProducts(); } else { $query = Product::find(); } $query->joinWith('variant'); - + + // Price filter fix + unset($params['prices']); + + FilterHelper::setQueryParams($query, $params); + $query->andWhere( + [ + '>=', + ProductVariant::tableName() . '.stock', + 1, + ] + ); return [ - 'min' => $query->min(ProductVariant::tableName() . '.price'), - 'max' => $query->max(ProductVariant::tableName() . '.price'), + 'min' => $query->min(ProductVariant::tableName() .'.price'), + 'max' => $query->max(ProductVariant::tableName() .'.price'), ]; } } \ No newline at end of file -- libgit2 0.21.4