Commit 5765cb7c8fb6d2041eb6e2b6e2f21ba3e2bf2542
1 parent
c9440a83
big commti
Showing
3 changed files
with
11 additions
and
18 deletions
Show diff stats
common/modules/product/helpers/ProductHelper.php
@@ -247,7 +247,7 @@ | @@ -247,7 +247,7 @@ | ||
247 | break; | 247 | break; |
248 | default: | 248 | default: |
249 | $query->andWhere( | 249 | $query->andWhere( |
250 | - Product::tableName() . '.product_id IN ( | 250 | + Product::tableName() . '.product_id IN ( |
251 | SELECT DISTINCT products | 251 | SELECT DISTINCT products |
252 | FROM ( | 252 | FROM ( |
253 | SELECT product_id AS products FROM product WHERE product_id IN( | 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,21 +120,6 @@ class CatalogController extends \yii\web\Controller | ||
120 | $groups = ArrayHelper::index($groups, null, 'name'); | 120 | $groups = ArrayHelper::index($groups, null, 'name'); |
121 | //$priceLimits = $productModel->priceLimits($category, $params); | 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 | return $this->render('products', [ | 124 | return $this->render('products', [ |
140 | 'category' => $category, | 125 | 'category' => $category, |
frontend/models/ProductFrontendSearch.php
@@ -7,6 +7,7 @@ use common\modules\product\models\Category; | @@ -7,6 +7,7 @@ use common\modules\product\models\Category; | ||
7 | use Yii; | 7 | use Yii; |
8 | use yii\base\Model; | 8 | use yii\base\Model; |
9 | use yii\data\ActiveDataProvider; | 9 | use yii\data\ActiveDataProvider; |
10 | +use yii\data\ArrayDataProvider; | ||
10 | use yii\db\ActiveQuery; | 11 | use yii\db\ActiveQuery; |
11 | 12 | ||
12 | use common\modules\product\models\Product; | 13 | use common\modules\product\models\Product; |
@@ -48,8 +49,15 @@ class ProductFrontendSearch extends Product { | @@ -48,8 +49,15 @@ class ProductFrontendSearch extends Product { | ||
48 | */ | 49 | */ |
49 | public function search($category = null, $params = [], $in_stock = true) { | 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 | 'pagination' => [ | 61 | 'pagination' => [ |
54 | 'pageSize' => 15, | 62 | 'pageSize' => 15, |
55 | ], | 63 | ], |