Commit ac8d2b24ad0c81fa09f979de143ef9d5646bf2d1

Authored by Administrator
1 parent 1e943c2b

add variantSku

Showing 2 changed files with 38 additions and 27 deletions   Show diff stats
helpers/FilterHelper.php
... ... @@ -245,29 +245,40 @@
245 245 * @var string $param Inputed keyword
246 246 */
247 247 foreach ($params as $param) {
248   - $conditions[] = [
249   - 'or',
250   - [
251   - 'ilike',
252   - ProductLang::tableName() . '.title',
253   - $param,
254   - ],
255   - [
256   - 'ilike',
257   - BrandLang::tableName() . '.title',
258   - $param,
259   - ],
260   - [
261   - 'ilike',
262   - CategoryLang::tableName() . '.title',
263   - $param,
264   - ],
265   - [
266   - 'ilike',
267   - ProductVariantLang::tableName() . '.title',
268   - $param,
269   - ],
270   - ];
  248 +
  249 + if(iconv_strlen($param) > 5){
  250 + $conditions[] = [
  251 + 'or',
  252 + [
  253 + 'ilike',
  254 + ProductLang::tableName() . '.title',
  255 + $param,
  256 + ],
  257 + [
  258 + 'ilike',
  259 + BrandLang::tableName() . '.title',
  260 + $param,
  261 + ],
  262 + [
  263 + 'ilike',
  264 + CategoryLang::tableName() . '.title',
  265 + $param,
  266 + ],
  267 + [
  268 + 'ilike',
  269 + ProductVariantLang::tableName() . '.title',
  270 + $param,
  271 + ],
  272 + [
  273 + 'ilike',
  274 + ProductVariant::tableName() . '.sku',
  275 + $param,
  276 + ]
  277 +
  278 + ];
  279 + }
  280 +
  281 +
271 282 }
272 283 }
273 284 if (count($conditions) > 1) {
... ...
models/ProductFrontendSearch.php
... ... @@ -94,11 +94,11 @@
94 94 ],
95 95 ]
96 96 );
97   -
98   - $dataProvider = new ArrayDataProvider(
  97 +
  98 + $dataProvider = new ActiveDataProvider(
99 99 [
100   - 'allModels' => $this->getSearchQuery($category, $params, $in_stock)
101   - ->with('variant', 'videos')->all(),
  100 + 'query' => $this->getSearchQuery($category, $params, $in_stock)
  101 + ->with('variant', 'videos'),
102 102 'pagination' => [
103 103 'pageSize' => 12,
104 104 ],
... ...