Commit a18604168028018a1430ddf4f7e014c6480d5261
1 parent
c91d116e
Items count for options
Showing
3 changed files
with
6 additions
and
1 deletions
Show diff stats
common/modules/rubrication/models/TaxOption.php
frontend/controllers/CatalogController.php
@@ -74,6 +74,10 @@ class CatalogController extends \yii\web\Controller | @@ -74,6 +74,10 @@ class CatalogController extends \yii\web\Controller | ||
74 | $brands_count = $brandsQuery->count(); | 74 | $brands_count = $brandsQuery->count(); |
75 | 75 | ||
76 | $optionsQuery = TaxOption::find() | 76 | $optionsQuery = TaxOption::find() |
77 | + ->select([ | ||
78 | + TaxOption::tableName() .'.*', | ||
79 | + 'COUNT('. ProductOption::tableName() .'.product_id) AS _items_count' | ||
80 | + ]) | ||
77 | ->innerJoin(ProductOption::tableName(), ProductOption::tableName() .'.option_id='. TaxOption::tableName() .'.tax_option_id') | 81 | ->innerJoin(ProductOption::tableName(), ProductOption::tableName() .'.option_id='. TaxOption::tableName() .'.tax_option_id') |
78 | ->innerJoin(ProductCategory::tableName(), ProductCategory::tableName() .'.product_id='. ProductOption::tableName() .'.product_id') | 82 | ->innerJoin(ProductCategory::tableName(), ProductCategory::tableName() .'.product_id='. ProductOption::tableName() .'.product_id') |
79 | ->where([ | 83 | ->where([ |
frontend/views/catalog/products.php
@@ -77,7 +77,7 @@ $this->params['breadcrumbs'][] = $category->name; | @@ -77,7 +77,7 @@ $this->params['breadcrumbs'][] = $category->name; | ||
77 | <?php foreach($group->_options as $option) :?> | 77 | <?php foreach($group->_options as $option) :?> |
78 | <div class="checkbox"> | 78 | <div class="checkbox"> |
79 | <label><input type="checkbox" name="option[<?= $group->alias?>][]" value="<?= $option->alias?>"<?= (isset($options[$group->alias]) && in_array($option->alias, $options[$group->alias])) ? ' checked' : ''?> /></label> | 79 | <label><input type="checkbox" name="option[<?= $group->alias?>][]" value="<?= $option->alias?>"<?= (isset($options[$group->alias]) && in_array($option->alias, $options[$group->alias])) ? ' checked' : ''?> /></label> |
80 | - <a href="#"><?= $option->ValueRenderHTML?></a> | 80 | + <a href="#"><?= $option->ValueRenderHTML?> (<?= $option->_items_count?>)</a> |
81 | </div> | 81 | </div> |
82 | <?php endforeach?> | 82 | <?php endforeach?> |
83 | </div> | 83 | </div> |