Commit a2d62946e4d351e36c9de37d97d98c3c40e03a44

Authored by Alexey Boroda
1 parent 79258b8f

-Data provider total count fixed

models/ProductActiveDataProvider.php 0 → 100644
  1 +<?php
  2 +
  3 + namespace artweb\artbox\ecommerce\models;
  4 +
  5 + use yii\base\InvalidConfigException;
  6 + use yii\data\ActiveDataProvider;
  7 + use yii\db\QueryInterface;
  8 +
  9 + class ProductActiveDataProvider extends ActiveDataProvider
  10 + {
  11 + /**
  12 + * @inheritdoc
  13 + */
  14 + protected function prepareTotalCount()
  15 + {
  16 + if (!$this->query instanceof QueryInterface) {
  17 + throw new InvalidConfigException('The "query" property must be an instance of a class that implements the QueryInterface e.g. yii\db\Query or its subclasses.');
  18 + }
  19 + $query = clone $this->query;
  20 +
  21 + return (int) $query->select('product.*')->limit(-1)->offset(-1)->orderBy([])->count('*', $this->db);
  22 + }
  23 + }
0 24 \ No newline at end of file
... ...
models/ProductFrontendSearch.php
... ... @@ -98,7 +98,7 @@
98 98 ]
99 99 );
100 100  
101   - $dataProvider = new ActiveDataProvider(
  101 + $dataProvider = new ProductActiveDataProvider(
102 102 [
103 103 'query' => $this->getSearchQuery($category, $params, $in_stock)->distinct()
104 104 ->select(['product.*','product_variant.price','product_lang.title'])
... ...