Commit 97edb6cec6bd928008c447311926998647cd3e78
1 parent
a7d38ea6
big commti
Showing
2 changed files
with
7 additions
and
5 deletions
Show diff stats
frontend/controllers/SearchController.php
... | ... | @@ -54,7 +54,7 @@ class SearchController extends \yii\web\Controller |
54 | 54 | } |
55 | 55 | |
56 | 56 | $productModel = new ProductFrontendSearch(); |
57 | - $productProvider = $productModel->search(null, $params); | |
57 | + $productProvider = $productModel->search(null, $params, false); | |
58 | 58 | |
59 | 59 | |
60 | 60 | return $this->render( | ... | ... |
frontend/models/ProductFrontendSearch.php
... | ... | @@ -48,10 +48,10 @@ class ProductFrontendSearch extends Product { |
48 | 48 | * |
49 | 49 | * @return ActiveDataProvider |
50 | 50 | */ |
51 | - public function search($category = null, $params = []) { | |
51 | + public function search($category = null, $params = [], $in_stock = true) { | |
52 | 52 | |
53 | 53 | $dataProvider = new ActiveDataProvider([ |
54 | - 'query' => $this->getSearchQuery($category, $params), | |
54 | + 'query' => $this->getSearchQuery($category, $params, $in_stock), | |
55 | 55 | 'pagination' => [ |
56 | 56 | 'pageSize' => 15, |
57 | 57 | ], |
... | ... | @@ -82,7 +82,7 @@ class ProductFrontendSearch extends Product { |
82 | 82 | return $dataProvider; |
83 | 83 | } |
84 | 84 | |
85 | - public function getSearchQuery($category = null, $params = []) { | |
85 | + public function getSearchQuery($category = null, $params = [], $in_stock = true) { | |
86 | 86 | if (!empty($category)) { |
87 | 87 | /** @var ActiveQuery $query */ |
88 | 88 | // $query = $category->getRelations('product_categories'); |
... | ... | @@ -96,8 +96,10 @@ class ProductFrontendSearch extends Product { |
96 | 96 | $query->groupBy(['product.product_id', 'product_variant.price']); |
97 | 97 | |
98 | 98 | ProductHelper::_setQueryParams($query, $params); |
99 | + if($in_stock){ | |
100 | + $query->andWhere(['!=', ProductVariant::tableName() .'.status', 1]); | |
101 | + } | |
99 | 102 | |
100 | - $query->andWhere(['!=', ProductVariant::tableName() .'.status', 1]); | |
101 | 103 | |
102 | 104 | return $query; |
103 | 105 | } | ... | ... |