Commit ac8ab861ee81bcc8b2f4fb4d393eaedc9227fb4a

Authored by Administrator
1 parent b5a6d518

20.07.16

backend/views/page/_form.php
@@ -15,6 +15,7 @@ use mihaildev\elfinder\ElFinder; @@ -15,6 +15,7 @@ use mihaildev\elfinder\ElFinder;
15 15
16 <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?> 16 <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
17 17
  18 + <?= $form->field($model, 'translit')->textInput(['maxlength' => true]) ?>
18 19
19 <?= $form->field($model, 'body')->widget(CKEditor::className(), 20 <?= $form->field($model, 'body')->widget(CKEditor::className(),
20 [ 21 [
common/modules/product/CatalogUrlManager.php
@@ -49,6 +49,7 @@ class CatalogUrlManager implements UrlRuleInterface { @@ -49,6 +49,7 @@ class CatalogUrlManager implements UrlRuleInterface {
49 49
50 if (strpos($paths[2], 'filters:') === 0) { 50 if (strpos($paths[2], 'filters:') === 0) {
51 $this->parseFilter($paths[2], $params); 51 $this->parseFilter($paths[2], $params);
  52 +
52 } 53 }
53 else if(strpos($paths[2], 'filter:') === 0){ 54 else if(strpos($paths[2], 'filter:') === 0){
54 $this->parseOldFilter($paths[2], $params); 55 $this->parseOldFilter($paths[2], $params);
@@ -84,21 +85,6 @@ class CatalogUrlManager implements UrlRuleInterface { @@ -84,21 +85,6 @@ class CatalogUrlManager implements UrlRuleInterface {
84 $params = [ 85 $params = [
85 'product' => $product, 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 return [$route, $params]; 90 return [$route, $params];
@@ -112,6 +98,7 @@ class CatalogUrlManager implements UrlRuleInterface { @@ -112,6 +98,7 @@ class CatalogUrlManager implements UrlRuleInterface {
112 */ 98 */
113 public function createUrl($manager, $route, $params) 99 public function createUrl($manager, $route, $params)
114 { 100 {
  101 +
115 if (!in_array($route, $this->route_map)) { 102 if (!in_array($route, $this->route_map)) {
116 return false; 103 return false;
117 } 104 }
@@ -150,25 +137,28 @@ class CatalogUrlManager implements UrlRuleInterface { @@ -150,25 +137,28 @@ class CatalogUrlManager implements UrlRuleInterface {
150 $url .= '?' . $query; 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 return $url; 142 return $url;
171 break; 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,18 +175,6 @@ class CatalogUrlManager implements UrlRuleInterface {
185 $filter[] = $key .'='. implode(':', $values); 175 $filter[] = $key .'='. implode(':', $values);
186 break; 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 default: 178 default:
201 foreach($values as &$value) { 179 foreach($values as &$value) {
202 $value = $this->option_value_encode($value); 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,6 +58,7 @@ return [
58 ], 58 ],
59 ], 59 ],
60 'components' => [ 60 'components' => [
  61 +
61 'authManager' => [ 62 'authManager' => [
62 'class' => 'yii\rbac\DbManager', 63 'class' => 'yii\rbac\DbManager',
63 ], 64 ],
@@ -120,7 +121,7 @@ return [ @@ -120,7 +121,7 @@ return [
120 'route_map' => [ 121 'route_map' => [
121 'catalog' => 'catalog/category', 122 'catalog' => 'catalog/category',
122 'product' => 'catalog/product', 123 'product' => 'catalog/product',
123 - 'brands' => 'catalog/brands', 124 +
124 ] 125 ]
125 ], 126 ],
126 'priceparam.xml' => 'site/priceparam', 127 'priceparam.xml' => 'site/priceparam',
@@ -134,31 +135,16 @@ return [ @@ -134,31 +135,16 @@ return [
134 // 'products/<translit:\w+>' => 'products/index', 135 // 'products/<translit:\w+>' => 'products/index',
135 // 'products/<translit_rubric:\w+>/<translit:[\w\-]+>-<id:\d+>' => 'products/show', 136 // 'products/<translit_rubric:\w+>/<translit:[\w\-]+>-<id:\d+>' => 'products/show',
136 'news/<translit:\w+>-<id:\d+>' => 'news/show', 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 'blog' => 'articles/index', 140 'blog' => 'articles/index',
140 'blog/<translit:[\w\-]+>-<id:\d+>' => 'articles/show', 141 'blog/<translit:[\w\-]+>-<id:\d+>' => 'articles/show',
141 'event' => 'event/index', 142 'event' => 'event/index',
142 - 'event/<alias:[\w\-]+>-<id:\d+>' => 'event/show', 143 + 'event/<alias:[\w\-]+>-<id:\d+>' => 'event/show',
143 '<language:(ru|ua|en)>/<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>', 144 '<language:(ru|ua|en)>/<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>',
144 '<language:(ru|ua|en)>/<controller:\w+>/<action:\w+>' => '<controller>/<action>', 145 '<language:(ru|ua|en)>/<controller:\w+>/<action:\w+>' => '<controller>/<action>',
145 '<language:(ru|ua|en)>/admin' => 'admin/default/index', 146 '<language:(ru|ua|en)>/admin' => 'admin/default/index',
146 '<language:(ru|ua|en)>/admin/users' => 'admin/users/index', 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 'thumbs/<path:.*>' => 'site/thumb', 148 'thumbs/<path:.*>' => 'site/thumb',
163 ], 149 ],
164 'class' => 'common\components\urlManager\LangUrlManager', 150 'class' => 'common\components\urlManager\LangUrlManager',
frontend/controllers/CatalogController.php
@@ -78,6 +78,12 @@ class CatalogController extends \yii\web\Controller @@ -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 foreach($optionsList as $optionList){ 87 foreach($optionsList as $optionList){
82 88
83 if(isset($filter[$optionList])){ 89 if(isset($filter[$optionList])){
@@ -87,10 +93,6 @@ class CatalogController extends \yii\web\Controller @@ -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 $productModel = new ProductFrontendSearch(); 96 $productModel = new ProductFrontendSearch();
95 //$productQuery = $productModel->getSearchQuery($category, $params); 97 //$productQuery = $productModel->getSearchQuery($category, $params);
96 $productProvider = $productModel->search($category, $params); 98 $productProvider = $productModel->search($category, $params);
@@ -175,31 +177,12 @@ class CatalogController extends \yii\web\Controller @@ -175,31 +177,12 @@ class CatalogController extends \yii\web\Controller
175 177
176 public function actionBrand($brand) 178 public function actionBrand($brand)
177 { 179 {
178 - $filter = Yii::$app->request->get('filter', []); 180 + $brand = BrandSearch::findByAlias($brand);
179 181
180 $params = [ 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 $productModel = new ProductFrontendSearch(); 186 $productModel = new ProductFrontendSearch();
204 $productProvider = $productModel->search(null, $params); 187 $productProvider = $productModel->search(null, $params);
205 188
@@ -210,7 +193,6 @@ class CatalogController extends \yii\web\Controller @@ -210,7 +193,6 @@ class CatalogController extends \yii\web\Controller
210 'productProvider' => $productProvider, 193 'productProvider' => $productProvider,
211 'brand' => $brand, 194 'brand' => $brand,
212 'priceLimits' => $priceLimits, 195 'priceLimits' => $priceLimits,
213 - 'filter' => $filter,  
214 ]); 196 ]);
215 } 197 }
216 198
frontend/views/articles/show.php
@@ -11,7 +11,7 @@ $this-&gt;registerMetaTag([&#39;name&#39; =&gt; &#39;description&#39;, &#39;content&#39; =&gt; $news-&gt;meta_descri @@ -11,7 +11,7 @@ $this-&gt;registerMetaTag([&#39;name&#39; =&gt; &#39;description&#39;, &#39;content&#39; =&gt; $news-&gt;meta_descri
11 <nav class="bread-crumbs"> 11 <nav class="bread-crumbs">
12 <?= Breadcrumbs::widget([ 12 <?= Breadcrumbs::widget([
13 'links' => [ 13 'links' => [
14 - ['label'=>'Блог','url'=>['blog/index']], 14 + ['label'=>'Блог','url'=>['/blog']],
15 $news->title 15 $news->title
16 ], 16 ],
17 ]) ?> 17 ]) ?>
frontend/views/catalog/brand.php
@@ -20,34 +20,6 @@ $this-&gt;registerCssFile (Yii::getAlias(&#39;@web/css/ion.rangeSlider.skinHTML5.css&#39;)) @@ -20,34 +20,6 @@ $this-&gt;registerCssFile (Yii::getAlias(&#39;@web/css/ion.rangeSlider.skinHTML5.css&#39;))
20 $this->registerJsFile (Yii::getAlias('@web/js/ion.rangeSlider.js')); 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 <nav class="bread-crumbs"> 24 <nav class="bread-crumbs">
53 <?= Breadcrumbs::widget ([ 25 <?= Breadcrumbs::widget ([
@@ -60,72 +32,9 @@ $this-&gt;registerJsFile (Yii::getAlias(&#39;@web/js/ion.rangeSlider.js&#39;)); @@ -60,72 +32,9 @@ $this-&gt;registerJsFile (Yii::getAlias(&#39;@web/js/ion.rangeSlider.js&#39;));
60 </nav> 32 </nav>
61 33
62 <div class="loyout"> 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 <div class="content"> 36 <div class="content">
114 <h1><?= $brand->name ?></h1> 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 <div class="products pn"> 38 <div class="products pn">
130 <ul> 39 <ul>
131 <?php foreach($productProvider->models as $product) :?> 40 <?php foreach($productProvider->models as $product) :?>
frontend/views/catalog/brands.php
@@ -24,9 +24,9 @@ $this-&gt;params[&#39;seo&#39;][&#39;key&#39;]= &#39;brands&#39;; @@ -24,9 +24,9 @@ $this-&gt;params[&#39;seo&#39;][&#39;key&#39;]= &#39;brands&#39;;
24 <ul class="brends_list"> 24 <ul class="brends_list">
25 <?php foreach($dataProvider->models as $brand) :?> 25 <?php foreach($dataProvider->models as $brand) :?>
26 <li> 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 <br> 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 </li> 30 </li>
31 <?php endforeach?> 31 <?php endforeach?>
32 </ul> 32 </ul>
frontend/widgets/Seo.php
@@ -135,7 +135,7 @@ class Seo extends Widget @@ -135,7 +135,7 @@ class Seo extends Widget
135 $title = $this->selectSeoData(self::TITLE); 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 $array = [ 140 $array = [
141 'category' => $this->category_name 141 'category' => $this->category_name