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