Commit 4fd39cf0b220d4e3c6488df9fe7f5f8412b7d0f6
1 parent
53c40309
Query fix in_stock added
Showing
1 changed file
with
7 additions
and
3 deletions
Show diff stats
helpers/FilterHelper.php
@@ -142,16 +142,17 @@ | @@ -142,16 +142,17 @@ | ||
142 | $query->andWhere([ 'product.id' => $last_query ]); | 142 | $query->andWhere([ 'product.id' => $last_query ]); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | - | 145 | + |
146 | /** | 146 | /** |
147 | * Tax Option filter | 147 | * Tax Option filter |
148 | * | 148 | * |
149 | * @param string[] $params | 149 | * @param string[] $params |
150 | * @param \yii\db\Query|null $last_query | 150 | * @param \yii\db\Query|null $last_query |
151 | + * @param bool $in_stock | ||
151 | * | 152 | * |
152 | - * @return Query | 153 | + * @return \yii\db\Query |
153 | */ | 154 | */ |
154 | - private static function filterOptions(array $params, Query $last_query = null): Query | 155 | + private static function filterOptions(array $params, Query $last_query = null, bool $in_stock = true): Query |
155 | { | 156 | { |
156 | $variant_query = ( new Query() )->distinct() | 157 | $variant_query = ( new Query() )->distinct() |
157 | ->select('product_variant.product_id as products') | 158 | ->select('product_variant.product_id as products') |
@@ -169,6 +170,9 @@ | @@ -169,6 +170,9 @@ | ||
169 | 'tax_option_lang.tax_option_id = tax_option.id' | 170 | 'tax_option_lang.tax_option_id = tax_option.id' |
170 | ) | 171 | ) |
171 | ->where([ 'tax_option_lang.alias' => $params ]); | 172 | ->where([ 'tax_option_lang.alias' => $params ]); |
173 | + if($in_stock) { | ||
174 | + $variant_query->andWhere(['!=', 'product_variant.stock', 0]); | ||
175 | + } | ||
172 | $product_query = ( new Query() )->distinct() | 176 | $product_query = ( new Query() )->distinct() |
173 | ->select('product_option.product_id as products') | 177 | ->select('product_option.product_id as products') |
174 | ->from('product_option') | 178 | ->from('product_option') |