Commit 93015018a2358aebbc4a5677f1055b8dfc5f06bf
1 parent
d52ef1bb
full commit
Showing
1 changed file
with
18 additions
and
7 deletions
Show diff stats
models/ProductFrontendSearch.php
... | ... | @@ -161,20 +161,31 @@ |
161 | 161 | * |
162 | 162 | * @return array |
163 | 163 | */ |
164 | - | |
165 | - public function priceLimits($category = null) | |
166 | - { | |
167 | - if (!empty( $category )) { | |
164 | + | |
165 | + public function priceLimits($category = null, $params = []) { | |
166 | + if (!empty($category)) { | |
168 | 167 | /** @var ActiveQuery $query */ |
168 | +// $query = $category->getRelations('product_categories'); | |
169 | 169 | $query = $category->getProducts(); |
170 | 170 | } else { |
171 | 171 | $query = Product::find(); |
172 | 172 | } |
173 | 173 | $query->joinWith('variant'); |
174 | - | |
174 | + | |
175 | + // Price filter fix | |
176 | + unset($params['prices']); | |
177 | + | |
178 | + FilterHelper::setQueryParams($query, $params); | |
179 | + $query->andWhere( | |
180 | + [ | |
181 | + '>=', | |
182 | + ProductVariant::tableName() . '.stock', | |
183 | + 1, | |
184 | + ] | |
185 | + ); | |
175 | 186 | return [ |
176 | - 'min' => $query->min(ProductVariant::tableName() . '.price'), | |
177 | - 'max' => $query->max(ProductVariant::tableName() . '.price'), | |
187 | + 'min' => $query->min(ProductVariant::tableName() .'.price'), | |
188 | + 'max' => $query->max(ProductVariant::tableName() .'.price'), | |
178 | 189 | ]; |
179 | 190 | } |
180 | 191 | } |
181 | 192 | \ No newline at end of file | ... | ... |