From ac8d2b24ad0c81fa09f979de143ef9d5646bf2d1 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 29 Nov 2016 23:01:16 +0200 Subject: [PATCH] add variantSku --- helpers/FilterHelper.php | 57 ++++++++++++++++++++++++++++++++++----------------------- models/ProductFrontendSearch.php | 8 ++++---- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/helpers/FilterHelper.php b/helpers/FilterHelper.php index 5113145..9f24ef1 100755 --- a/helpers/FilterHelper.php +++ b/helpers/FilterHelper.php @@ -245,29 +245,40 @@ * @var string $param Inputed keyword */ foreach ($params as $param) { - $conditions[] = [ - 'or', - [ - 'ilike', - ProductLang::tableName() . '.title', - $param, - ], - [ - 'ilike', - BrandLang::tableName() . '.title', - $param, - ], - [ - 'ilike', - CategoryLang::tableName() . '.title', - $param, - ], - [ - 'ilike', - ProductVariantLang::tableName() . '.title', - $param, - ], - ]; + + if(iconv_strlen($param) > 5){ + $conditions[] = [ + 'or', + [ + 'ilike', + ProductLang::tableName() . '.title', + $param, + ], + [ + 'ilike', + BrandLang::tableName() . '.title', + $param, + ], + [ + 'ilike', + CategoryLang::tableName() . '.title', + $param, + ], + [ + 'ilike', + ProductVariantLang::tableName() . '.title', + $param, + ], + [ + 'ilike', + ProductVariant::tableName() . '.sku', + $param, + ] + + ]; + } + + } } if (count($conditions) > 1) { diff --git a/models/ProductFrontendSearch.php b/models/ProductFrontendSearch.php index db53867..6cb5082 100755 --- a/models/ProductFrontendSearch.php +++ b/models/ProductFrontendSearch.php @@ -94,11 +94,11 @@ ], ] ); - - $dataProvider = new ArrayDataProvider( + + $dataProvider = new ActiveDataProvider( [ - 'allModels' => $this->getSearchQuery($category, $params, $in_stock) - ->with('variant', 'videos')->all(), + 'query' => $this->getSearchQuery($category, $params, $in_stock) + ->with('variant', 'videos'), 'pagination' => [ 'pageSize' => 12, ], -- libgit2 0.21.4