diff --git a/common/modules/product/models/Product.php b/common/modules/product/models/Product.php index 09f8f6a..4b723ae 100755 --- a/common/modules/product/models/Product.php +++ b/common/modules/product/models/Product.php @@ -281,19 +281,26 @@ class Product extends \yii\db\ActiveRecord } public function getActiveProperties($category_id) { - $groups = $options = []; - foreach ($this->options as $option) { - $options[$option->tax_group_id][] = $option; - } + $cacheKey = ['ActiveProperties','id' => $category_id]; - $taxGroups = TaxGroup::find()->joinWith('categories')->where(['tax_group.tax_group_id' => array_keys($options), 'tax_group.display' => TRUE, 'category.category_id' => $category_id])->all(); + if(!$groups = Yii::$app->cache->get($cacheKey)){ - foreach ($taxGroups as $group) { - if (!empty($options[$group->tax_group_id])) { - $group->_options = $options[$group->tax_group_id]; - $groups[] = $group; + $groups = $options = []; + foreach ($this->options as $option) { + $options[$option->tax_group_id][] = $option; + } + + $taxGroups = TaxGroup::find()->joinWith('categories')->where(['tax_group.tax_group_id' => array_keys($options), 'tax_group.display' => TRUE, 'category.category_id' => $category_id])->all(); + + foreach ($taxGroups as $group) { + if (!empty($options[$group->tax_group_id])) { + $group->_options = $options[$group->tax_group_id]; + $groups[] = $group; + } } + Yii::$app->cache->set($cacheKey,$groups); } + return $groups; } diff --git a/frontend/controllers/CatalogController.php b/frontend/controllers/CatalogController.php index de5a57a..2396035 100755 --- a/frontend/controllers/CatalogController.php +++ b/frontend/controllers/CatalogController.php @@ -125,6 +125,7 @@ class CatalogController extends \yii\web\Controller */ $query = $productProvider->query; $query->with([ + 'events', 'variant', 'comments', 'averageRating', diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index f214af1..d1626a5 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -258,7 +258,9 @@ use common\models\Event;