diff --git a/helpers/CatalogFilterHelper.php b/helpers/CatalogFilterHelper.php index e1c1cfe..9b3bfdb 100755 --- a/helpers/CatalogFilterHelper.php +++ b/helpers/CatalogFilterHelper.php @@ -320,12 +320,12 @@ class CatalogFilterHelper extends Object */ private static function filterPrices(array $params, array &$filters) { - $filterP['nested']['path'] = 'variants'; + $filterP = []; if (!empty( $params[ 'min' ] ) && $params[ 'min' ] > 0) { - $filterP['nested']['query']['bool']['filter'][]['range']['variants.price']['gte'] = $params[ 'min' ]; + $filterP['nested']['query']['bool']['filter'][]['range']['price']['gte'] = $params[ 'min' ]; } if (!empty( $params[ 'max' ] ) && $params[ 'max' ] > 0) { - $filterP['nested']['query']['bool']['filter'][]['range']['variants.price']['lte'] = $params[ 'max' ]; + $filterP['nested']['query']['bool']['filter'][]['range']['price']['lte'] = $params[ 'max' ]; } $filters['bool']['must'][] = $filterP; diff --git a/models/Product.php b/models/Product.php index e727ac0..82fea3d 100755 --- a/models/Product.php +++ b/models/Product.php @@ -332,7 +332,21 @@ ] ); } - + + + public function getMaxPrice(){ + $price = 0; + if (!empty( $this->enabledVariants )) { + foreach ( $this->enabledVariants as $variant){ + if($variant->price > $price){ + $price = $variant->price; + } + } + } + return $price; + } + + /** * Get random ProductVariant price or 0 if not exist * -- libgit2 0.21.4