Commit ac8ab861ee81bcc8b2f4fb4d393eaedc9227fb4a
1 parent
b5a6d518
20.07.16
Showing
10 changed files
with
84 additions
and
182 deletions
Show diff stats
backend/views/page/_form.php
... | ... | @@ -15,6 +15,7 @@ use mihaildev\elfinder\ElFinder; |
15 | 15 | |
16 | 16 | <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?> |
17 | 17 | |
18 | + <?= $form->field($model, 'translit')->textInput(['maxlength' => true]) ?> | |
18 | 19 | |
19 | 20 | <?= $form->field($model, 'body')->widget(CKEditor::className(), |
20 | 21 | [ | ... | ... |
common/modules/product/CatalogUrlManager.php
... | ... | @@ -49,6 +49,7 @@ class CatalogUrlManager implements UrlRuleInterface { |
49 | 49 | |
50 | 50 | if (strpos($paths[2], 'filters:') === 0) { |
51 | 51 | $this->parseFilter($paths[2], $params); |
52 | + | |
52 | 53 | } |
53 | 54 | else if(strpos($paths[2], 'filter:') === 0){ |
54 | 55 | $this->parseOldFilter($paths[2], $params); |
... | ... | @@ -84,21 +85,6 @@ class CatalogUrlManager implements UrlRuleInterface { |
84 | 85 | $params = [ |
85 | 86 | 'product' => $product, |
86 | 87 | ]; |
87 | - } elseif ($paths[0] == 'brands') { | |
88 | - if (empty($paths[1]) || $paths[1] == 'index') { | |
89 | - $route = 'catalog/brands'; | |
90 | - } elseif (($brand = BrandSearch::findByAlias($paths[1]))) { | |
91 | - $route = 'catalog/brand'; | |
92 | - $params['brand'] = $brand; | |
93 | - if (!empty($paths[2])) { | |
94 | - // Filter | |
95 | - if (strpos($paths[2], 'filters:') === 0) { | |
96 | - $this->parseFilter($paths[2], $params); | |
97 | - } | |
98 | - } | |
99 | - } else { | |
100 | - // @todo redirect or return FALSE | |
101 | - } | |
102 | 88 | } |
103 | 89 | |
104 | 90 | return [$route, $params]; |
... | ... | @@ -112,6 +98,7 @@ class CatalogUrlManager implements UrlRuleInterface { |
112 | 98 | */ |
113 | 99 | public function createUrl($manager, $route, $params) |
114 | 100 | { |
101 | + | |
115 | 102 | if (!in_array($route, $this->route_map)) { |
116 | 103 | return false; |
117 | 104 | } |
... | ... | @@ -150,25 +137,28 @@ class CatalogUrlManager implements UrlRuleInterface { |
150 | 137 | $url .= '?' . $query; |
151 | 138 | } |
152 | 139 | |
153 | - return $url; | |
154 | - break; | |
155 | 140 | |
156 | - case 'catalog/brands': | |
157 | - if (empty($params['brand'])) { | |
158 | - return 'brands'; | |
159 | - } else { | |
160 | - $brand_alias = is_object($params['brand']) ? $params['brand']->alias : strtolower($params['brand']); | |
161 | - } | |
162 | - $url = 'brands/'. $brand_alias .'/'; | |
163 | - | |
164 | - $this->setFilterUrl($params, $url); | |
165 | - | |
166 | - if (!empty($params) && ($query = http_build_query($params)) !== '') { | |
167 | - $url .= '?' . $query; | |
168 | - } | |
169 | 141 | |
170 | 142 | return $url; |
171 | 143 | break; |
144 | + | |
145 | +// case 'catalog/brands': | |
146 | +// if (empty($params['brand'])) { | |
147 | +// return 'brands'; | |
148 | +// } else { | |
149 | +// | |
150 | +// $brand_alias = is_object($params['brand']) ? $params['brand']->alias : strtolower($params['brand']); | |
151 | +// } | |
152 | +// $url = 'brands/'. $brand_alias .'/'; | |
153 | + | |
154 | +// $this->setFilterUrl($params, $url); | |
155 | +// | |
156 | +// if (!empty($params) && ($query = http_build_query($params)) !== '') { | |
157 | +// $url .= '?' . $query; | |
158 | +// } | |
159 | +// | |
160 | +// return $url; | |
161 | +// break; | |
172 | 162 | } |
173 | 163 | } |
174 | 164 | |
... | ... | @@ -185,18 +175,6 @@ class CatalogUrlManager implements UrlRuleInterface { |
185 | 175 | $filter[] = $key .'='. implode(':', $values); |
186 | 176 | break; |
187 | 177 | |
188 | -// case 'options': | |
189 | -// foreach($values as $group => &$value_items) { | |
190 | -// foreach($value_items as &$value_item) { | |
191 | -// $value_item = $this->option_value_encode($value_item); | |
192 | -// if (empty($value_item)) { | |
193 | -// unset($value_item); | |
194 | -// } | |
195 | -// } | |
196 | -// $filter[] = $this->option_prefix. $group .'='. implode(',', $value_items); | |
197 | -// } | |
198 | -// break; | |
199 | - | |
200 | 178 | default: |
201 | 179 | foreach($values as &$value) { |
202 | 180 | $value = $this->option_value_encode($value); | ... | ... |
console/migrations/m160722_150101_remove_product_option_option_fkey.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +class m160722_150101_remove_product_option_option_fkey extends Migration | |
6 | +{ | |
7 | + public function up() | |
8 | + { | |
9 | + $this->dropForeignKey('product_option_option_fkey', '{{%product_option}}'); | |
10 | + | |
11 | + } | |
12 | + | |
13 | + public function down() | |
14 | + { | |
15 | + $this->addForeignKey('product_option_option_fkey', 'product_option', 'option_id', 'tax_option', 'tax_option_id', 'NO ACTION', 'NO ACTION'); | |
16 | + | |
17 | + } | |
18 | + | |
19 | +} | ... | ... |
console/migrations/m160722_150611_remove_product_variant_option_id.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +class m160722_150611_remove_product_variant_option_id extends Migration | |
6 | +{ | |
7 | + public function up() | |
8 | + { | |
9 | + $this->dropForeignKey('product_variant_option_id', '{{%product_variant_option}}'); | |
10 | + } | |
11 | + | |
12 | + public function down() | |
13 | + { | |
14 | + $this->addForeignKey('product_variant_option_id', 'product_variant_option', 'option_variant_id', 'tax_option', 'tax_option_id', 'NO ACTION', 'NO ACTION'); | |
15 | + } | |
16 | + | |
17 | + /* | |
18 | + // Use safeUp/safeDown to run migration code within a transaction | |
19 | + public function safeUp() | |
20 | + { | |
21 | + } | |
22 | + | |
23 | + public function safeDown() | |
24 | + { | |
25 | + } | |
26 | + */ | |
27 | +} | ... | ... |
frontend/config/main.php
... | ... | @@ -58,6 +58,7 @@ return [ |
58 | 58 | ], |
59 | 59 | ], |
60 | 60 | 'components' => [ |
61 | + | |
61 | 62 | 'authManager' => [ |
62 | 63 | 'class' => 'yii\rbac\DbManager', |
63 | 64 | ], |
... | ... | @@ -120,7 +121,7 @@ return [ |
120 | 121 | 'route_map' => [ |
121 | 122 | 'catalog' => 'catalog/category', |
122 | 123 | 'product' => 'catalog/product', |
123 | - 'brands' => 'catalog/brands', | |
124 | + | |
124 | 125 | ] |
125 | 126 | ], |
126 | 127 | 'priceparam.xml' => 'site/priceparam', |
... | ... | @@ -134,31 +135,16 @@ return [ |
134 | 135 | // 'products/<translit:\w+>' => 'products/index', |
135 | 136 | // 'products/<translit_rubric:\w+>/<translit:[\w\-]+>-<id:\d+>' => 'products/show', |
136 | 137 | 'news/<translit:\w+>-<id:\d+>' => 'news/show', |
137 | - //'brends/<translit:[\w\-]+>' => 'brends/show', | |
138 | - 'brends' => 'brends/index', | |
138 | + 'brands' => 'catalog/brands', | |
139 | + 'brands/<brand:[\w\-]+>' => 'catalog/brand', | |
139 | 140 | 'blog' => 'articles/index', |
140 | 141 | 'blog/<translit:[\w\-]+>-<id:\d+>' => 'articles/show', |
141 | 142 | 'event' => 'event/index', |
142 | - 'event/<alias:[\w\-]+>-<id:\d+>' => 'event/show', | |
143 | + 'event/<alias:[\w\-]+>-<id:\d+>' => 'event/show', | |
143 | 144 | '<language:(ru|ua|en)>/<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>', |
144 | 145 | '<language:(ru|ua|en)>/<controller:\w+>/<action:\w+>' => '<controller>/<action>', |
145 | 146 | '<language:(ru|ua|en)>/admin' => 'admin/default/index', |
146 | 147 | '<language:(ru|ua|en)>/admin/users' => 'admin/users/index', |
147 | - 'admin' => 'admin/menu/index', | |
148 | - 'admin/users' => 'admin/users/index', | |
149 | - 'admin/users/save' => 'admin/users/save', | |
150 | - 'admin/users/delete' => 'admin/users/delete', | |
151 | - 'admin/menu' => 'admin/menu/index', | |
152 | - 'admin/menu/save' => 'admin/menu/save', | |
153 | - 'admin/menu/delete' => 'admin/menu/delete', | |
154 | - 'admin/text' => 'admin/text/index', | |
155 | - 'admin/text/save' => 'admin/text/save', | |
156 | - 'admin/text/delete' => 'admin/text/delete', | |
157 | - 'admin/catalog' => 'admin/catalog/index', | |
158 | - 'admin/catalog/save' => 'admin/catalog/save', | |
159 | - 'admin/catalog/delete' => 'admin/catalog/delete', | |
160 | - | |
161 | - | |
162 | 148 | 'thumbs/<path:.*>' => 'site/thumb', |
163 | 149 | ], |
164 | 150 | 'class' => 'common\components\urlManager\LangUrlManager', | ... | ... |
frontend/controllers/CatalogController.php
... | ... | @@ -78,6 +78,12 @@ class CatalogController extends \yii\web\Controller |
78 | 78 | // } |
79 | 79 | |
80 | 80 | |
81 | + if ( !empty($filter['prices']) ) { | |
82 | + $params['prices'] = $filter['prices']; | |
83 | + } | |
84 | + | |
85 | + | |
86 | + | |
81 | 87 | foreach($optionsList as $optionList){ |
82 | 88 | |
83 | 89 | if(isset($filter[$optionList])){ |
... | ... | @@ -87,10 +93,6 @@ class CatalogController extends \yii\web\Controller |
87 | 93 | } |
88 | 94 | |
89 | 95 | |
90 | - if ( !empty($filter['prices']) ) { | |
91 | - $params['prices'] = $filter['prices']; | |
92 | - } | |
93 | - | |
94 | 96 | $productModel = new ProductFrontendSearch(); |
95 | 97 | //$productQuery = $productModel->getSearchQuery($category, $params); |
96 | 98 | $productProvider = $productModel->search($category, $params); |
... | ... | @@ -175,31 +177,12 @@ class CatalogController extends \yii\web\Controller |
175 | 177 | |
176 | 178 | public function actionBrand($brand) |
177 | 179 | { |
178 | - $filter = Yii::$app->request->get('filter', []); | |
180 | + $brand = BrandSearch::findByAlias($brand); | |
179 | 181 | |
180 | 182 | $params = [ |
181 | - 'brand_id' => $brand->brand_id, | |
183 | + 'brands' => $brand->brand_id, | |
182 | 184 | ]; |
183 | 185 | |
184 | - if ( !empty($filter['prices']) ) { | |
185 | - $params['prices'] = $filter['prices']; | |
186 | - } | |
187 | - | |
188 | - if ( !empty($filter['special']) ) { | |
189 | - if (!is_array($filter['special'])) { | |
190 | - $filter['special'] = [$filter['special']]; | |
191 | - } | |
192 | - if (in_array('new', $filter['special'])) { | |
193 | - $params['special']['is_new'] = true; | |
194 | - } | |
195 | - if (in_array('top', $filter['special'])) { | |
196 | - $params['special']['is_top'] = true; | |
197 | - } | |
198 | - if (in_array('promo', $filter['special'])) { | |
199 | - $params['special']['akciya'] = true; | |
200 | - } | |
201 | - } | |
202 | - | |
203 | 186 | $productModel = new ProductFrontendSearch(); |
204 | 187 | $productProvider = $productModel->search(null, $params); |
205 | 188 | |
... | ... | @@ -210,7 +193,6 @@ class CatalogController extends \yii\web\Controller |
210 | 193 | 'productProvider' => $productProvider, |
211 | 194 | 'brand' => $brand, |
212 | 195 | 'priceLimits' => $priceLimits, |
213 | - 'filter' => $filter, | |
214 | 196 | ]); |
215 | 197 | } |
216 | 198 | ... | ... |
frontend/views/articles/show.php
... | ... | @@ -11,7 +11,7 @@ $this->registerMetaTag(['name' => 'description', 'content' => $news->meta_descri |
11 | 11 | <nav class="bread-crumbs"> |
12 | 12 | <?= Breadcrumbs::widget([ |
13 | 13 | 'links' => [ |
14 | - ['label'=>'Блог','url'=>['blog/index']], | |
14 | + ['label'=>'Блог','url'=>['/blog']], | |
15 | 15 | $news->title |
16 | 16 | ], |
17 | 17 | ]) ?> | ... | ... |
frontend/views/catalog/brand.php
... | ... | @@ -20,34 +20,6 @@ $this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.skinHTML5.css')) |
20 | 20 | $this->registerJsFile (Yii::getAlias('@web/js/ion.rangeSlider.js')); |
21 | 21 | ?> |
22 | 22 | |
23 | -<script type="text/javascript"> | |
24 | - <?php if ($priceLimits['min'] < $priceLimits['max']) :?> | |
25 | - $(document).ready(function() { | |
26 | - // price rangeslider (filter price slider) | |
27 | - $("#price_interval").ionRangeSlider({ | |
28 | - type: "double", | |
29 | - min: <?= $priceLimits['min']?>, | |
30 | - max: <?= $priceLimits['max']?>, | |
31 | - from: <?= empty($filter['prices']['min']) ? $priceLimits['min'] : $filter['prices']['min']?>, | |
32 | - to: <?= empty($filter['prices']['max']) ? $priceLimits['max'] : $filter['prices']['max']?>, | |
33 | - grid: false, | |
34 | - onFinish: function(e) { | |
35 | - <?php | |
36 | - $filterWhitoutPrice = $filter; | |
37 | - $filterWhitoutPrice['prices'] = [ | |
38 | - 'min' => '{from}', | |
39 | - 'max' => '{to}', | |
40 | - ]; | |
41 | - ?> | |
42 | - var url = "<?= Url::to(['catalog/brands', 'brand' => $brand, 'filter' => $filterWhitoutPrice])?>"; | |
43 | - var from = e.from; | |
44 | - var to = e.to; | |
45 | - document.location = url.replace('{from}', from).replace('{to}', to); | |
46 | - } | |
47 | - }); | |
48 | - }); | |
49 | - <?php endif?> | |
50 | -</script> | |
51 | 23 | |
52 | 24 | <nav class="bread-crumbs"> |
53 | 25 | <?= Breadcrumbs::widget ([ |
... | ... | @@ -60,72 +32,9 @@ $this->registerJsFile (Yii::getAlias('@web/js/ion.rangeSlider.js')); |
60 | 32 | </nav> |
61 | 33 | |
62 | 34 | <div class="loyout"> |
63 | - <div class="leftbar"> | |
64 | - <div class="filters"> | |
65 | - <ul> | |
66 | - <li class="new"> | |
67 | - <?php | |
68 | - $checked = !empty($filter['special']) && in_array('new', $filter['special']); | |
69 | - $option_url = Url::to(['catalog/brands', 'brand' => $brand, 'filter' => ProductHelper::getFilterForOption($filter, 'special', 'new', $checked)]); | |
70 | - ?> | |
71 | - <input type="checkbox" class="special-option" <?= $checked ? ' checked' : ''?> onchange="document.location='<?= $option_url?>'" /> | |
72 | - <a href="<?= $option_url?>"><?= Yii::t('product', 'New products')?></a> | |
73 | - </li> | |
74 | - <li class="top"> | |
75 | - <?php | |
76 | - $checked = !empty($filter['special']) && in_array('top', $filter['special']); | |
77 | - $option_url = Url::to(['catalog/brands', 'brand' => $brand, 'filter' => ProductHelper::getFilterForOption($filter, 'special', 'top', $checked)]); | |
78 | - ?> | |
79 | - <input type="checkbox" class="special-option" <?= $checked ? ' checked' : ''?> onchange="document.location='<?= $option_url?>'" /> | |
80 | - <a href="<?= $option_url?>"><?= Yii::t('product', 'Top products')?></a> | |
81 | - </li> | |
82 | - <li class="promo"> | |
83 | - <?php | |
84 | - $checked = !empty($filter['special']) && in_array('promo', $filter['special']); | |
85 | - $option_url = Url::to(['catalog/brands', 'brand' => $brand, 'filter' => ProductHelper::getFilterForOption($filter, 'special', 'promo', $checked)]); | |
86 | - ?> | |
87 | - <input type="checkbox" class="special-option" <?= $checked ? ' checked' : ''?> onchange="document.location='<?= $option_url?>'" /> | |
88 | - <a href="<?= $option_url?>"><?= Yii::t('product', 'Promo products')?></a> | |
89 | - </li> | |
90 | - </ul> | |
91 | - </div> | |
92 | - <form action="#" name="filter_catalog_page_form" class="filter-catalog-form"> | |
93 | - <?php if (!empty($filter)) :?> | |
94 | - <div class="filter_accept_bloc"> | |
95 | - <!-- <button type="submit" class="filter_accept_btn">применить</button>--> | |
96 | - <a href="<?= Url::to(['catalog/brands', 'brand' => $brand])?>" class="_form_checkbox_reset">сбросить фильтры</a> | |
97 | - </div> | |
98 | - <?php endif?> | |
99 | - | |
100 | - <?php if ($priceLimits['min'] < $priceLimits['max']) :?> | |
101 | - <div class="cost_box filters"> | |
102 | - <div class="begin">Цена</div> | |
103 | - <div class="price_filter first_price_li"> | |
104 | - <div class="price_slider"> | |
105 | - <input type="text" id="price_interval" name="price_interval" value="" /> | |
106 | - </div> | |
107 | - </div> | |
108 | - </div> | |
109 | - <?php endif?> | |
110 | - </form> | |
111 | - </div> | |
112 | 35 | |
113 | 36 | <div class="content"> |
114 | 37 | <h1><?= $brand->name ?></h1> |
115 | - <div class="sort_menu"> | |
116 | - | |
117 | - <div class="sort_block"> | |
118 | - <span>Сортировка:</span> | |
119 | - <?= \yii\widgets\LinkSorter::widget([ | |
120 | - 'sort' => $productProvider->sort, | |
121 | - 'attributes' => [ | |
122 | - 'name', | |
123 | - 'price', | |
124 | - ] | |
125 | - ]); | |
126 | - ?> | |
127 | - </div> | |
128 | - </div> | |
129 | 38 | <div class="products pn"> |
130 | 39 | <ul> |
131 | 40 | <?php foreach($productProvider->models as $product) :?> | ... | ... |
frontend/views/catalog/brands.php
... | ... | @@ -24,9 +24,9 @@ $this->params['seo']['key']= 'brands'; |
24 | 24 | <ul class="brends_list"> |
25 | 25 | <?php foreach($dataProvider->models as $brand) :?> |
26 | 26 | <li> |
27 | - <a href="<?= \yii\helpers\Url::to(['catalog/brands', 'brand' => $brand])?>"><?= \common\components\artboximage\ArtboxImageHelper::getImage($brand->imageUrl, 'brand_item')?></a> | |
27 | + <a href="<?= \yii\helpers\Url::to(['catalog/brand', 'brand' => $brand->alias])?>"><?= \common\components\artboximage\ArtboxImageHelper::getImage($brand->imageUrl, 'brand_item')?></a> | |
28 | 28 | <br> |
29 | - <a href="<?= \yii\helpers\Url::to(['catalog/brands', 'brand' => $brand])?>" class="name"><?= $brand->name?></a> | |
29 | + <a href="<?= \yii\helpers\Url::to(['catalog/brand', 'brand' => $brand->alias])?>" class="name"><?= $brand->name?></a> | |
30 | 30 | </li> |
31 | 31 | <?php endforeach?> |
32 | 32 | </ul> | ... | ... |
frontend/widgets/Seo.php
... | ... | @@ -135,7 +135,7 @@ class Seo extends Widget |
135 | 135 | $title = $this->selectSeoData(self::TITLE); |
136 | 136 | |
137 | 137 | |
138 | - if(!empty($filter) && $title == $this->fields['meta-title']) { | |
138 | + if(!empty($filter) && isset($this->fields['meta-title']) && $title == $this->fields['meta-title']) { | |
139 | 139 | |
140 | 140 | $array = [ |
141 | 141 | 'category' => $this->category_name | ... | ... |