Commit 5765cb7c8fb6d2041eb6e2b6e2f21ba3e2bf2542

Authored by Administrator
1 parent c9440a83

big commti

common/modules/product/helpers/ProductHelper.php
... ... @@ -247,7 +247,7 @@
247 247 break;
248 248 default:
249 249 $query->andWhere(
250   - Product::tableName() . '.product_id IN (
  250 + Product::tableName() . '.product_id IN (
251 251 SELECT DISTINCT products
252 252 FROM (
253 253 SELECT product_id AS products FROM product WHERE product_id IN(
... ...
frontend/controllers/CatalogController.php
... ... @@ -120,21 +120,6 @@ class CatalogController extends \yii\web\Controller
120 120 $groups = ArrayHelper::index($groups, null, 'name');
121 121 //$priceLimits = $productModel->priceLimits($category, $params);
122 122  
123   - /*
124   - * Greedy search for comments and rating
125   - */
126   - $query = $productProvider->query;
127   - $query->with([
128   - 'images',
129   - 'events',
130   - 'variant',
131   - 'variant.image',
132   - 'comments',
133   - 'averageRating',
134   - ]);
135   - /*
136   - * End of greedy search for rating and comments
137   - */
138 123  
139 124 return $this->render('products', [
140 125 'category' => $category,
... ...
frontend/models/ProductFrontendSearch.php
... ... @@ -7,6 +7,7 @@ use common\modules\product\models\Category;
7 7 use Yii;
8 8 use yii\base\Model;
9 9 use yii\data\ActiveDataProvider;
  10 +use yii\data\ArrayDataProvider;
10 11 use yii\db\ActiveQuery;
11 12  
12 13 use common\modules\product\models\Product;
... ... @@ -48,8 +49,15 @@ class ProductFrontendSearch extends Product {
48 49 */
49 50 public function search($category = null, $params = [], $in_stock = true) {
50 51  
51   - $dataProvider = new ActiveDataProvider([
52   - 'query' => $this->getSearchQuery($category, $params, $in_stock),
  52 + $dataProvider = new ArrayDataProvider([
  53 + 'allModels' => $this->getSearchQuery($category, $params, $in_stock)->with([
  54 + 'images',
  55 + 'events',
  56 + 'variant',
  57 + 'variant.image',
  58 + 'comments',
  59 + 'averageRating',
  60 + ])->all(),
53 61 'pagination' => [
54 62 'pageSize' => 15,
55 63 ],
... ...