From 879394e30e695daa464734509eb672147b55f223 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Sun, 4 Dec 2016 02:12:00 +0200 Subject: [PATCH] add variantSku --- helpers/FilterHelper.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/helpers/FilterHelper.php b/helpers/FilterHelper.php index 696c6b1..61839d7 100755 --- a/helpers/FilterHelper.php +++ b/helpers/FilterHelper.php @@ -215,10 +215,11 @@ * * @param string[] $params * @param \yii\db\Query|null $last_query + * @param bool $in_stock * - * @return Query + * @return \yii\db\Query */ - private static function filterOptions(array $params, Query $last_query = null): Query + private static function filterOptions(array $params, Query $last_query = null, bool $in_stock = true): Query { $variant_query = ( new Query() )->distinct() @@ -237,6 +238,9 @@ 'tax_option_lang.tax_option_id = tax_option.id' ) ->where([ 'tax_option_lang.alias' => $params ]); + if($in_stock) { + $variant_query->andWhere(['!=', 'product_variant.stock', 0]); + } $product_query = ( new Query() )->distinct() ->select('product_option.product_id as products') ->from('product_option') -- libgit2 0.21.4