Commit ea57d22abebc8fcf9d1184324176667067327763
1 parent
41f0c492
site map
Showing
2 changed files
with
18 additions
and
4 deletions
Show diff stats
helpers/CatalogFilterHelper.php
| ... | ... | @@ -320,12 +320,12 @@ class CatalogFilterHelper extends Object |
| 320 | 320 | */ |
| 321 | 321 | private static function filterPrices(array $params, array &$filters) |
| 322 | 322 | { |
| 323 | - $filterP['nested']['path'] = 'variants'; | |
| 323 | + $filterP = []; | |
| 324 | 324 | if (!empty( $params[ 'min' ] ) && $params[ 'min' ] > 0) { |
| 325 | - $filterP['nested']['query']['bool']['filter'][]['range']['variants.price']['gte'] = $params[ 'min' ]; | |
| 325 | + $filterP['nested']['query']['bool']['filter'][]['range']['price']['gte'] = $params[ 'min' ]; | |
| 326 | 326 | } |
| 327 | 327 | if (!empty( $params[ 'max' ] ) && $params[ 'max' ] > 0) { |
| 328 | - $filterP['nested']['query']['bool']['filter'][]['range']['variants.price']['lte'] = $params[ 'max' ]; | |
| 328 | + $filterP['nested']['query']['bool']['filter'][]['range']['price']['lte'] = $params[ 'max' ]; | |
| 329 | 329 | } |
| 330 | 330 | $filters['bool']['must'][] = $filterP; |
| 331 | 331 | ... | ... |
models/Product.php
| ... | ... | @@ -332,7 +332,21 @@ |
| 332 | 332 | ] |
| 333 | 333 | ); |
| 334 | 334 | } |
| 335 | - | |
| 335 | + | |
| 336 | + | |
| 337 | + public function getMaxPrice(){ | |
| 338 | + $price = 0; | |
| 339 | + if (!empty( $this->enabledVariants )) { | |
| 340 | + foreach ( $this->enabledVariants as $variant){ | |
| 341 | + if($variant->price > $price){ | |
| 342 | + $price = $variant->price; | |
| 343 | + } | |
| 344 | + } | |
| 345 | + } | |
| 346 | + return $price; | |
| 347 | + } | |
| 348 | + | |
| 349 | + | |
| 336 | 350 | /** |
| 337 | 351 | * Get random ProductVariant price or 0 if not exist |
| 338 | 352 | * | ... | ... |