Commit 865853392105a844d92d0be5601da92037b29749
Merge remote-tracking branch 'origin/master'
Showing
8 changed files
with
76 additions
and
27 deletions
Show diff stats
common/modules/product/models/BrandQuery.php
| @@ -31,4 +31,15 @@ class BrandQuery extends \yii\db\ActiveQuery | @@ -31,4 +31,15 @@ class BrandQuery extends \yii\db\ActiveQuery | ||
| 31 | { | 31 | { |
| 32 | return parent::one($db); | 32 | return parent::one($db); |
| 33 | } | 33 | } |
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * Select brand by alias | ||
| 37 | + * @param $slug | ||
| 38 | + * @return $this | ||
| 39 | + */ | ||
| 40 | + public function byAlias($alias) | ||
| 41 | + { | ||
| 42 | + $this->andFilterWhere(['alias' => $alias]); | ||
| 43 | + return $this; | ||
| 44 | + } | ||
| 34 | } | 45 | } |
common/modules/product/models/Category.php
| @@ -82,11 +82,12 @@ class Category extends \yii\db\ActiveRecord | @@ -82,11 +82,12 @@ class Category extends \yii\db\ActiveRecord | ||
| 82 | [['name'], 'required'], | 82 | [['name'], 'required'], |
| 83 | [['parent_id', 'depth', 'category_name_id', 'product_unit_id'], 'integer'], | 83 | [['parent_id', 'depth', 'category_name_id', 'product_unit_id'], 'integer'], |
| 84 | [['path', 'meta_desc', 'seo_text'], 'string'], | 84 | [['path', 'meta_desc', 'seo_text'], 'string'], |
| 85 | - [['image', 'meta_title'], 'string', 'max' => 255], | 85 | + [['meta_title'], 'string', 'max' => 255], |
| 86 | [['meta_robots'], 'string', 'max' => 50], | 86 | [['meta_robots'], 'string', 'max' => 50], |
| 87 | [['alias', 'name'], 'string', 'max' => 250], | 87 | [['alias', 'name'], 'string', 'max' => 250], |
| 88 | [['populary'], 'boolean'], | 88 | [['populary'], 'boolean'], |
| 89 | [['group_to_category'], 'safe'], | 89 | [['group_to_category'], 'safe'], |
| 90 | + // [['image'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, gif'], | ||
| 90 | // [['product_unit_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductUnit::className(), 'targetAttribute' => ['product_unit_id' => 'product_unit_id']], | 91 | // [['product_unit_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductUnit::className(), 'targetAttribute' => ['product_unit_id' => 'product_unit_id']], |
| 91 | ]; | 92 | ]; |
| 92 | } | 93 | } |
common/modules/product/widgets/views/submenu.php
| @@ -8,7 +8,13 @@ | @@ -8,7 +8,13 @@ | ||
| 8 | <div class="content_items"> | 8 | <div class="content_items"> |
| 9 | <?php foreach($populary as $_item) :?> | 9 | <?php foreach($populary as $_item) :?> |
| 10 | <div class="content_item"><a href="<?= \yii\helpers\Url::to(['catalog/category', 'alias' => $_item->alias])?>"> | 10 | <div class="content_item"><a href="<?= \yii\helpers\Url::to(['catalog/category', 'alias' => $_item->alias])?>"> |
| 11 | - <div valign="top" class="picture"><img valign="top" src="<?= $_item->image?>"></div> | 11 | + <div valign="top" class="picture"> |
| 12 | + <?php if (empty($_item->image)) :?> | ||
| 13 | + <img valign="top" src="/images/no_photo.png"> | ||
| 14 | + <?php else :?> | ||
| 15 | + <img valign="top" src="<?= $_item->image?>"> | ||
| 16 | + <?php endif?> | ||
| 17 | + </div> | ||
| 12 | <div class="title"><?= $_item->name?></div> | 18 | <div class="title"><?= $_item->name?></div> |
| 13 | </a></div> | 19 | </a></div> |
| 14 | <?php endforeach?> | 20 | <?php endforeach?> |
| @@ -24,7 +30,13 @@ | @@ -24,7 +30,13 @@ | ||
| 24 | <div class="content_items"> | 30 | <div class="content_items"> |
| 25 | <?php foreach($item['children'] as $_item) :?> | 31 | <?php foreach($item['children'] as $_item) :?> |
| 26 | <div class="content_item"><a href="<?= \yii\helpers\Url::to(['/catalog/category', 'alias' => $_item['item']->alias])?>"> | 32 | <div class="content_item"><a href="<?= \yii\helpers\Url::to(['/catalog/category', 'alias' => $_item['item']->alias])?>"> |
| 27 | - <div valign="top" class="picture"><img valign="top" src="<?= $_item['item']->image?>"></div> | 33 | + <div valign="top" class="picture"> |
| 34 | + <?php if (empty($_item['item']->image)) :?> | ||
| 35 | + <img valign="top" src="/images/no_photo.png"> | ||
| 36 | + <?php else :?> | ||
| 37 | + <img valign="top" src="<?= $_item['item']->image?>" alt="<?= $_item['item']->name?>"> | ||
| 38 | + <?php endif?> | ||
| 39 | + </div> | ||
| 28 | <div class="title"><?= $_item['item']->name?></div> | 40 | <div class="title"><?= $_item['item']->name?></div> |
| 29 | </a></div> | 41 | </a></div> |
| 30 | <?php endforeach?> | 42 | <?php endforeach?> |
frontend/config/main.php
| @@ -47,6 +47,7 @@ return [ | @@ -47,6 +47,7 @@ return [ | ||
| 47 | 'enablePrettyUrl' => true, | 47 | 'enablePrettyUrl' => true, |
| 48 | 'showScriptName' => false, | 48 | 'showScriptName' => false, |
| 49 | 'rules' => [ | 49 | 'rules' => [ |
| 50 | +// 'catalog' => 'catalog/category', | ||
| 50 | 'catalog/<alias:[A-Za-z0-9_-]+>' => 'catalog/category', | 51 | 'catalog/<alias:[A-Za-z0-9_-]+>' => 'catalog/category', |
| 51 | 'product/<alias:[A-Za-z0-9_-]+>' => 'catalog/product', | 52 | 'product/<alias:[A-Za-z0-9_-]+>' => 'catalog/product', |
| 52 | 'brand' => 'catalog/brands', | 53 | 'brand' => 'catalog/brands', |
frontend/controllers/CatalogController.php
| @@ -20,6 +20,10 @@ use yii\web\HttpException; | @@ -20,6 +20,10 @@ use yii\web\HttpException; | ||
| 20 | 20 | ||
| 21 | class CatalogController extends \yii\web\Controller | 21 | class CatalogController extends \yii\web\Controller |
| 22 | { | 22 | { |
| 23 | + public function actionSearch() { | ||
| 24 | + | ||
| 25 | + } | ||
| 26 | + | ||
| 23 | public function actionCategory($alias) | 27 | public function actionCategory($alias) |
| 24 | { | 28 | { |
| 25 | $category = CategorySearch::findByAlias($alias); | 29 | $category = CategorySearch::findByAlias($alias); |
| @@ -116,14 +120,31 @@ class CatalogController extends \yii\web\Controller | @@ -116,14 +120,31 @@ class CatalogController extends \yii\web\Controller | ||
| 116 | 120 | ||
| 117 | // Options | 121 | // Options |
| 118 | if (($options = \Yii::$app->request->get('option')) != false) { | 122 | if (($options = \Yii::$app->request->get('option')) != false) { |
| 119 | - $query->innerJoin(ProductOption::tableName(), ProductOption::tableName() .'.product_id='. Product::tableName() .'.product_id'); | ||
| 120 | - $query->innerJoin(TaxOption::tableName(), TaxOption::tableName() .'.tax_option_id='. ProductOption::tableName() .'.option_id'); | ||
| 121 | - 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 | + } | ||
| 122 | $group = TaxGroup::find()->where(['like', 'alias', $group_alias])->one(); | 132 | $group = TaxGroup::find()->where(['like', 'alias', $group_alias])->one(); |
| 123 | if (!$group) { | 133 | if (!$group) { |
| 124 | continue; | 134 | continue; |
| 125 | } | 135 | } |
| 126 | - $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) .'))'); |
| 137 | + } | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + if (($_brands = \Yii::$app->request->get('brand')) != false && is_array($_brands) && count($_brands) > 0) { | ||
| 141 | + $_brands = Brand::find()->where(['in', 'alias', $_brands])->all(); | ||
| 142 | + $bids = []; | ||
| 143 | + foreach ($_brands as $brand) { | ||
| 144 | + $bids[] = $brand->brand_id; | ||
| 145 | + } | ||
| 146 | + if (count($bids)) { | ||
| 147 | + $query->andWhere([Product::tableName() .'.brand_id' => $bids]); | ||
| 127 | } | 148 | } |
| 128 | } | 149 | } |
| 129 | 150 |
frontend/views/catalog/products.php
| @@ -55,8 +55,8 @@ $this->params['breadcrumbs'][] = $category->name; | @@ -55,8 +55,8 @@ $this->params['breadcrumbs'][] = $category->name; | ||
| 55 | <div class="price_filter"> | 55 | <div class="price_filter"> |
| 56 | <?php foreach($brands as $brand) :?> | 56 | <?php foreach($brands as $brand) :?> |
| 57 | <div class="checkbox"> | 57 | <div class="checkbox"> |
| 58 | - <label><input type="checkbox" name="think" value="ruuki" /></label> | ||
| 59 | - <a href="<?= \yii\helpers\Url::to(['catalog/brand', 'alias' => $brand->alias])?>"><?= $brand->name?> (<?= $brand->getProducts()->count()?>)</a> | 58 | + <label><input type="checkbox" name="brand[]" value="<?= $brand->alias?>"<?= isset($_GET['brand']) && in_array($brand->alias, $_GET['brand']) ? ' checked' : ''?> /></label> |
| 59 | + <a href="#<?php /*= \yii\helpers\Url::to(['brand', 'alias' => $brand->alias])*/?>"><?= $brand->name?><!-- (<?php /*= $brand->getProducts()->count()*/?>)--></a> | ||
| 60 | </div> | 60 | </div> |
| 61 | <?php endforeach?> | 61 | <?php endforeach?> |
| 62 | <!--<div class="checkbox see_all"> | 62 | <!--<div class="checkbox see_all"> |
| @@ -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 | ||
| @@ -243,7 +247,7 @@ $this->params['breadcrumbs'][] = $category->name; | @@ -243,7 +247,7 @@ $this->params['breadcrumbs'][] = $category->name; | ||
| 243 | 247 | ||
| 244 | <?php if ($pages->totalCount > $pages->pageSize) :?> | 248 | <?php if ($pages->totalCount > $pages->pageSize) :?> |
| 245 | <!-- LOAD MORE BUTTON --> | 249 | <!-- LOAD MORE BUTTON --> |
| 246 | - <button class="load_more_btn">Загрузить еще <?= $per_page?> товара</button> | 250 | + <!--button class="load_more_btn">Загрузить еще <?= $per_page?> товара</button--> |
| 247 | 251 | ||
| 248 | <div class="show_pages"> | 252 | <div class="show_pages"> |
| 249 | Страница: | 253 | Страница: |
| @@ -257,27 +261,18 @@ $this->params['breadcrumbs'][] = $category->name; | @@ -257,27 +261,18 @@ $this->params['breadcrumbs'][] = $category->name; | ||
| 257 | <?php endif?> | 261 | <?php endif?> |
| 258 | <hr> | 262 | <hr> |
| 259 | 263 | ||
| 264 | + <?php if(!empty($category->description)) :?> | ||
| 260 | <div class="description"> | 265 | <div class="description"> |
| 261 | - <h2>Преимущества металлочерепицы:</h2> | ||
| 262 | - <p> | ||
| 263 | - На рынке стройматериалов представлено множество кровельных покрытий, от привычного всем рубероида до современной гибкой черепицы на основе стекловолоконных композитов. Все они имеют свои преимущества и сферы применения. Но металлочерепица на протяжении многих лет удерживает лидерские позиции по уровню продаж, и этzо объясняется несколькими причинами: | ||
| 264 | - </p> | ||
| 265 | - <h4>Кровля из металлочерепицы</h4> | ||
| 266 | - <p class="margin_bottom_20"> | ||
| 267 | - <span class="bold">1. Малый вес.</span> Эта характеристика дает ощутимую финансовую выгоду. Вам не придется усиливать стропильные конструкции, значит, удастся сэкономить на пиломатериалах. Легкость металлочерепицы для кровли упрощает транспортировку и монтаж, позволяет отказаться от дорогостоящих услуг подъемной и грузовой спецтехники. | ||
| 268 | - </p> | ||
| 269 | - <p class="margin_bottom_20"> | ||
| 270 | - <span class="bold">2. Прочность.</span> В отличие от рулонных и гибких материалов, металлочерепица устойчива к механическим повреждениям. Ее крайне сложно поцарапать и практически невозможно сломать. Высокие технические характеристики говорят и о хорошей несущей способности материала. | ||
| 271 | - </p> | ||
| 272 | - <p class="margin_bottom_20"> | ||
| 273 | - <span class="bold">3. Эстетичность.</span> Металлочерепица придает крыше законченный, аккуратный вид. Дом выглядит просто роскошно. Подбирая оригинальные цветовые сочетания, дизайнерам удается с помощью | ||
| 274 | - </p> | 266 | + <?= $category->description?> |
| 275 | 267 | ||
| 276 | <div class="empty_padding_400"></div> | 268 | <div class="empty_padding_400"></div> |
| 277 | </div> | 269 | </div> |
| 270 | + <?php endif?> | ||
| 278 | </div> | 271 | </div> |
| 279 | </div> | 272 | </div> |
| 280 | </div> | 273 | </div> |
| 274 | + | ||
| 275 | + <?php endif?> | ||
| 281 | </div> | 276 | </div> |
| 282 | </div> | 277 | </div> |
| 283 | 278 |
frontend/views/layouts/main.php
| @@ -54,9 +54,11 @@ AppAsset::register($this); | @@ -54,9 +54,11 @@ AppAsset::register($this); | ||
| 54 | <?= Html::a(Html::img('/images/bau_logo.png',['border'=>'0']), ['/'],['class'=>'head_up_cell bau_logo'])?> | 54 | <?= Html::a(Html::img('/images/bau_logo.png',['border'=>'0']), ['/'],['class'=>'head_up_cell bau_logo'])?> |
| 55 | <div class="head_up_cell srch"> | 55 | <div class="head_up_cell srch"> |
| 56 | <div class="search_head"> | 56 | <div class="search_head"> |
| 57 | - <div class="srch_head_desc">Введите запрос <a href="#">Шифер</a> <a href="#">Рубероид</a></div> | ||
| 58 | - <input type="text" name="search_head"> | ||
| 59 | - <button><div class="search_img"></div></button> | 57 | + <form action="<?= Url::to('catalog')?>"> |
| 58 | + <div class="srch_head_desc">Введите запрос <a href="#" onclick="$('#search-head').val('Шифер');return false;">Шифер</a> <a href="#" onclick="$('#search-head').val('Рубероид');return false;">Рубероид</a></div> | ||
| 59 | + <input type="text" name="word" id="search-head"> | ||
| 60 | + <button><div class="search_img"></div></button> | ||
| 61 | + </form> | ||
| 60 | </div> | 62 | </div> |
| 61 | </div> | 63 | </div> |
| 62 | <div class="head_up_cell phn"> | 64 | <div class="head_up_cell phn"> |
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 { |