diff --git a/common/modules/product/helpers/ProductHelper.php b/common/modules/product/helpers/ProductHelper.php index 780b0a3..a6ff9db 100755 --- a/common/modules/product/helpers/ProductHelper.php +++ b/common/modules/product/helpers/ProductHelper.php @@ -247,7 +247,7 @@ break; default: $query->andWhere( - Product::tableName() . '.product_id IN ( + Product::tableName() . '.product_id IN ( SELECT DISTINCT products FROM ( SELECT product_id AS products FROM product WHERE product_id IN( diff --git a/frontend/controllers/CatalogController.php b/frontend/controllers/CatalogController.php index 14ecb55..8af5b2f 100755 --- a/frontend/controllers/CatalogController.php +++ b/frontend/controllers/CatalogController.php @@ -120,21 +120,6 @@ class CatalogController extends \yii\web\Controller $groups = ArrayHelper::index($groups, null, 'name'); //$priceLimits = $productModel->priceLimits($category, $params); - /* - * Greedy search for comments and rating - */ - $query = $productProvider->query; - $query->with([ - 'images', - 'events', - 'variant', - 'variant.image', - 'comments', - 'averageRating', - ]); - /* - * End of greedy search for rating and comments - */ return $this->render('products', [ 'category' => $category, diff --git a/frontend/models/ProductFrontendSearch.php b/frontend/models/ProductFrontendSearch.php index 2188630..bcef1a5 100755 --- a/frontend/models/ProductFrontendSearch.php +++ b/frontend/models/ProductFrontendSearch.php @@ -7,6 +7,7 @@ use common\modules\product\models\Category; use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; +use yii\data\ArrayDataProvider; use yii\db\ActiveQuery; use common\modules\product\models\Product; @@ -48,8 +49,15 @@ class ProductFrontendSearch extends Product { */ public function search($category = null, $params = [], $in_stock = true) { - $dataProvider = new ActiveDataProvider([ - 'query' => $this->getSearchQuery($category, $params, $in_stock), + $dataProvider = new ArrayDataProvider([ + 'allModels' => $this->getSearchQuery($category, $params, $in_stock)->with([ + 'images', + 'events', + 'variant', + 'variant.image', + 'comments', + 'averageRating', + ])->all(), 'pagination' => [ 'pageSize' => 15, ], -- libgit2 0.21.4