Commit 3523d4884138e33bfb8170288981ff94889f7aef
1 parent
8bef359d
big commti
Showing
3 changed files
with
20 additions
and
10 deletions
Show diff stats
common/modules/product/models/Product.php
@@ -281,19 +281,26 @@ class Product extends \yii\db\ActiveRecord | @@ -281,19 +281,26 @@ class Product extends \yii\db\ActiveRecord | ||
281 | } | 281 | } |
282 | 282 | ||
283 | public function getActiveProperties($category_id) { | 283 | public function getActiveProperties($category_id) { |
284 | - $groups = $options = []; | ||
285 | - foreach ($this->options as $option) { | ||
286 | - $options[$option->tax_group_id][] = $option; | ||
287 | - } | 284 | + $cacheKey = ['ActiveProperties','id' => $category_id]; |
288 | 285 | ||
289 | - $taxGroups = TaxGroup::find()->joinWith('categories')->where(['tax_group.tax_group_id' => array_keys($options), 'tax_group.display' => TRUE, 'category.category_id' => $category_id])->all(); | 286 | + if(!$groups = Yii::$app->cache->get($cacheKey)){ |
290 | 287 | ||
291 | - foreach ($taxGroups as $group) { | ||
292 | - if (!empty($options[$group->tax_group_id])) { | ||
293 | - $group->_options = $options[$group->tax_group_id]; | ||
294 | - $groups[] = $group; | 288 | + $groups = $options = []; |
289 | + foreach ($this->options as $option) { | ||
290 | + $options[$option->tax_group_id][] = $option; | ||
291 | + } | ||
292 | + | ||
293 | + $taxGroups = TaxGroup::find()->joinWith('categories')->where(['tax_group.tax_group_id' => array_keys($options), 'tax_group.display' => TRUE, 'category.category_id' => $category_id])->all(); | ||
294 | + | ||
295 | + foreach ($taxGroups as $group) { | ||
296 | + if (!empty($options[$group->tax_group_id])) { | ||
297 | + $group->_options = $options[$group->tax_group_id]; | ||
298 | + $groups[] = $group; | ||
299 | + } | ||
295 | } | 300 | } |
301 | + Yii::$app->cache->set($cacheKey,$groups); | ||
296 | } | 302 | } |
303 | + | ||
297 | return $groups; | 304 | return $groups; |
298 | } | 305 | } |
299 | 306 |
frontend/controllers/CatalogController.php
@@ -125,6 +125,7 @@ class CatalogController extends \yii\web\Controller | @@ -125,6 +125,7 @@ class CatalogController extends \yii\web\Controller | ||
125 | */ | 125 | */ |
126 | $query = $productProvider->query; | 126 | $query = $productProvider->query; |
127 | $query->with([ | 127 | $query->with([ |
128 | + 'events', | ||
128 | 'variant', | 129 | 'variant', |
129 | 'comments', | 130 | 'comments', |
130 | 'averageRating', | 131 | 'averageRating', |
frontend/views/layouts/main.php
@@ -258,7 +258,9 @@ use common\models\Event; | @@ -258,7 +258,9 @@ use common\models\Event; | ||
258 | <div class="col-md-12"> | 258 | <div class="col-md-12"> |
259 | <div class="row"> | 259 | <div class="row"> |
260 | <div class="col-md-4"> | 260 | <div class="col-md-4"> |
261 | - <?php if($this->beginCache('articles_show',3600*24) ){?> | 261 | + <?php if($this->beginCache('articles_show',[ |
262 | + 'duration' => 3600*24 | ||
263 | + ]) ){?> | ||
262 | <span class="posts-title">Статьи</span> | 264 | <span class="posts-title">Статьи</span> |
263 | <ul class="posts-links style"> | 265 | <ul class="posts-links style"> |
264 | <?php foreach(Articles::find()->all() as $article):?> | 266 | <?php foreach(Articles::find()->all() as $article):?> |