Commit 2c4d173e4cb48a56c2952a8e0c8caf77a515a256
1 parent
3ed4a4cd
Base-product#6 functional
Showing
3 changed files
with
22 additions
and
4 deletions
Show diff stats
frontend/controllers/CatalogController.php
@@ -120,14 +120,20 @@ class CatalogController extends \yii\web\Controller | @@ -120,14 +120,20 @@ class CatalogController extends \yii\web\Controller | ||
120 | 120 | ||
121 | // Options | 121 | // Options |
122 | if (($options = \Yii::$app->request->get('option')) != false) { | 122 | if (($options = \Yii::$app->request->get('option')) != false) { |
123 | - $query->innerJoin(ProductOption::tableName(), ProductOption::tableName() .'.product_id='. Product::tableName() .'.product_id'); | ||
124 | - $query->innerJoin(TaxOption::tableName(), TaxOption::tableName() .'.tax_option_id='. ProductOption::tableName() .'.option_id'); | ||
125 | - foreach($options as $group_alias => $option_alias) { | 123 | +// $query->innerJoin(ProductOption::tableName(), ProductOption::tableName() .'.product_id='. Product::tableName() .'.product_id'); |
124 | +// $query->innerJoin(TaxOption::tableName(), TaxOption::tableName() .'.tax_option_id='. ProductOption::tableName() .'.option_id'); | ||
125 | + foreach($options as $group_alias => $options_alias) { | ||
126 | + if (!is_array($options_alias)) { | ||
127 | + $options_alias = [$options_alias]; | ||
128 | + } | ||
129 | + foreach($options_alias as &$option_alias) { | ||
130 | + $option_alias = "'". $option_alias ."'"; | ||
131 | + } | ||
126 | $group = TaxGroup::find()->where(['like', 'alias', $group_alias])->one(); | 132 | $group = TaxGroup::find()->where(['like', 'alias', $group_alias])->one(); |
127 | if (!$group) { | 133 | if (!$group) { |
128 | continue; | 134 | continue; |
129 | } | 135 | } |
130 | - $query->andWhere([TaxOption::tableName() .'.tax_group_id' => $group->tax_group_id, TaxOption::tableName() .'.alias' => $option_alias]); | 136 | + $query->andWhere(Product::tableName() .'.product_id IN (SELECT product_id FROM product_option INNER JOIN tax_option ON tax_option.tax_option_id = product_option.option_id WHERE tax_option.alias IN ('. implode(',', $options_alias) .'))'); |
131 | } | 137 | } |
132 | } | 138 | } |
133 | 139 |
frontend/views/catalog/products.php
@@ -186,6 +186,10 @@ $this->params['breadcrumbs'][] = $category->name; | @@ -186,6 +186,10 @@ $this->params['breadcrumbs'][] = $category->name; | ||
186 | <div class="cat_p_catalog_list"> | 186 | <div class="cat_p_catalog_list"> |
187 | <div class="title"><?= $category->name?> <span>(<?= $all_count?>)</span></div> | 187 | <div class="title"><?= $category->name?> <span>(<?= $all_count?>)</span></div> |
188 | 188 | ||
189 | + <?php if (empty($products)) :?> | ||
190 | + <h2>По данному запросу товары не найдены.</h2><br> | ||
191 | + <p>Показать <a href="<?= \yii\helpers\Url::to(['catalog/category', 'alias' => $category->alias])?>">все товары из категории "<?= $category->name?>"</a></p> | ||
192 | + <?php else :?> | ||
189 | <!-- sort menu --> | 193 | <!-- sort menu --> |
190 | <div class="sort_menu"> | 194 | <div class="sort_menu"> |
191 | 195 | ||
@@ -267,6 +271,8 @@ $this->params['breadcrumbs'][] = $category->name; | @@ -267,6 +271,8 @@ $this->params['breadcrumbs'][] = $category->name; | ||
267 | </div> | 271 | </div> |
268 | </div> | 272 | </div> |
269 | </div> | 273 | </div> |
274 | + | ||
275 | + <?php endif?> | ||
270 | </div> | 276 | </div> |
271 | </div> | 277 | </div> |
272 | 278 |
frontend/web/css/concat_all.css
@@ -43,6 +43,11 @@ | @@ -43,6 +43,11 @@ | ||
43 | display: inline-block; | 43 | display: inline-block; |
44 | float: left; | 44 | float: left; |
45 | } | 45 | } |
46 | +.cat_p_filter_bar:before { | ||
47 | + display: block; | ||
48 | + content: ''; | ||
49 | + clear: both; | ||
50 | +} | ||
46 | 51 | ||
47 | .cat_p_filter_bar .filter_list ul { | 52 | .cat_p_filter_bar .filter_list ul { |
48 | list-style: none; | 53 | list-style: none; |
@@ -190,6 +195,7 @@ | @@ -190,6 +195,7 @@ | ||
190 | width: 700px; | 195 | width: 700px; |
191 | padding-right: 10px; | 196 | padding-right: 10px; |
192 | display: inline-block; | 197 | display: inline-block; |
198 | + min-height: 20em; | ||
193 | } | 199 | } |
194 | 200 | ||
195 | .cat_p_catalog_list ul { | 201 | .cat_p_catalog_list ul { |