Commit ddf2d8f9261262eeb9af271bb2e3fbe4a40c624a
1 parent
906f0fd5
big commti
Showing
2 changed files
with
17 additions
and
75 deletions
Show diff stats
common/modules/product/CatalogUrlManager.php
@@ -2,12 +2,10 @@ | @@ -2,12 +2,10 @@ | ||
2 | 2 | ||
3 | namespace common\modules\product; | 3 | namespace common\modules\product; |
4 | 4 | ||
5 | -use common\modules\product\helpers\FilterHelper; | ||
6 | -use common\modules\product\models\Brand; | ||
7 | -use common\modules\product\models\BrandSearch; | 5 | + |
8 | use common\modules\product\models\CategorySearch; | 6 | use common\modules\product\models\CategorySearch; |
9 | use common\modules\product\models\ProductSearch; | 7 | use common\modules\product\models\ProductSearch; |
10 | -use common\modules\rubrication\models\TaxOption; | 8 | + |
11 | use Yii; | 9 | use Yii; |
12 | use yii\helpers\Url; | 10 | use yii\helpers\Url; |
13 | use yii\web\HttpException; | 11 | use yii\web\HttpException; |
@@ -15,8 +13,6 @@ use yii\web\UrlRuleInterface; | @@ -15,8 +13,6 @@ use yii\web\UrlRuleInterface; | ||
15 | 13 | ||
16 | class CatalogUrlManager implements UrlRuleInterface { | 14 | class CatalogUrlManager implements UrlRuleInterface { |
17 | public $route_map = []; | 15 | public $route_map = []; |
18 | - | ||
19 | - public $option_prefix = 'o:'; | ||
20 | /** | 16 | /** |
21 | * Parses the given request and returns the corresponding route and parameters. | 17 | * Parses the given request and returns the corresponding route and parameters. |
22 | * @param \yii\web\UrlManager $manager the URL manager | 18 | * @param \yii\web\UrlManager $manager the URL manager |
@@ -29,6 +25,12 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -29,6 +25,12 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
29 | $pathInfo = $request->getPathInfo(); | 25 | $pathInfo = $request->getPathInfo(); |
30 | $paths = explode('/', $pathInfo); | 26 | $paths = explode('/', $pathInfo); |
31 | 27 | ||
28 | + if(isset($paths[1])) { | ||
29 | + if(strripos($request->url,'catalog/'.$paths[1].'?') && (!strripos($request->url,'?page')) && (!strripos($request->url,'?sort'))){ | ||
30 | + throw new HttpException(404 ,'Page not found'); | ||
31 | + } | ||
32 | + | ||
33 | + } | ||
32 | 34 | ||
33 | 35 | ||
34 | if (!array_key_exists($paths[0], $this->route_map)) { | 36 | if (!array_key_exists($paths[0], $this->route_map)) { |
@@ -54,24 +56,6 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -54,24 +56,6 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
54 | $this->parseFilter($paths[2], $params); | 56 | $this->parseFilter($paths[2], $params); |
55 | 57 | ||
56 | } | 58 | } |
57 | - else if(strpos($paths[2], 'filter:') === 0){ | ||
58 | - $this->parseOldFilter($paths[2], $params); | ||
59 | - //['catalog/category', 'category' => $category, 'filters' =>$params['filter']] | ||
60 | - | ||
61 | - $optionsTemplate = FilterHelper::optionsTemplate(); | ||
62 | - array_unshift($optionsTemplate, "special", "brands"); | ||
63 | - $filterView = []; | ||
64 | - foreach($optionsTemplate as $optionKey){ | ||
65 | - if(isset($params['filter'][$optionKey])){ | ||
66 | - $filterView[$optionKey] = $params['filter'][$optionKey]; | ||
67 | - } | ||
68 | - | ||
69 | - | ||
70 | - } | ||
71 | - | ||
72 | - | ||
73 | - Yii::$app->response->redirect(['catalog/category', 'category' => $category, 'filters' =>$filterView],301); | ||
74 | - } | ||
75 | else { | 59 | else { |
76 | throw new HttpException(404 ,'Page not found'); | 60 | throw new HttpException(404 ,'Page not found'); |
77 | } | 61 | } |
@@ -111,6 +95,7 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -111,6 +95,7 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
111 | if (!empty($params['category'])) { | 95 | if (!empty($params['category'])) { |
112 | $category_alias = is_object($params['category']) ? $params['category']->alias : strtolower($params['category']); | 96 | $category_alias = is_object($params['category']) ? $params['category']->alias : strtolower($params['category']); |
113 | $url = 'catalog/'. $category_alias .'/'; | 97 | $url = 'catalog/'. $category_alias .'/'; |
98 | + unset($params['category']); | ||
114 | } else { | 99 | } else { |
115 | $url = 'catalog/'; | 100 | $url = 'catalog/'; |
116 | } | 101 | } |
@@ -133,6 +118,7 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -133,6 +118,7 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
133 | case 'catalog/product': | 118 | case 'catalog/product': |
134 | if (!empty($params['product'])) { | 119 | if (!empty($params['product'])) { |
135 | $product_alias = is_object($params['product']) ? $params['product']->alias : strtolower($params['product']); | 120 | $product_alias = is_object($params['product']) ? $params['product']->alias : strtolower($params['product']); |
121 | + unset($params['product']); | ||
136 | } | 122 | } |
137 | $url = 'product/'. $product_alias; | 123 | $url = 'product/'. $product_alias; |
138 | 124 | ||
@@ -145,23 +131,6 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -145,23 +131,6 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
145 | return $url; | 131 | return $url; |
146 | break; | 132 | break; |
147 | 133 | ||
148 | -// case 'catalog/brands': | ||
149 | -// if (empty($params['brand'])) { | ||
150 | -// return 'brands'; | ||
151 | -// } else { | ||
152 | -// | ||
153 | -// $brand_alias = is_object($params['brand']) ? $params['brand']->alias : strtolower($params['brand']); | ||
154 | -// } | ||
155 | -// $url = 'brands/'. $brand_alias .'/'; | ||
156 | -// | ||
157 | -// $this->setFilterUrl($params, $url); | ||
158 | -// | ||
159 | -// if (!empty($params) && ($query = http_build_query($params)) !== '') { | ||
160 | -// $url .= '?' . $query; | ||
161 | -// } | ||
162 | -// | ||
163 | -// return $url; | ||
164 | -// break; | ||
165 | } | 134 | } |
166 | } | 135 | } |
167 | 136 | ||
@@ -201,12 +170,8 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -201,12 +170,8 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
201 | $filter_str = substr($paths, 8); | 170 | $filter_str = substr($paths, 8); |
202 | $filter_options = explode(';', $filter_str); | 171 | $filter_options = explode(';', $filter_str); |
203 | foreach ($filter_options as $filter_option) { | 172 | foreach ($filter_options as $filter_option) { |
204 | - if (empty($filter_option)) { | ||
205 | - continue; | ||
206 | - } | ||
207 | $filter_exp = explode('=', $filter_option); | 173 | $filter_exp = explode('=', $filter_option); |
208 | - | ||
209 | - if(isset($filter_exp[1])){ | 174 | + if(is_array($filter_exp)){ |
210 | list($filter_key, $filter_option) = explode('=', $filter_option); | 175 | list($filter_key, $filter_option) = explode('=', $filter_option); |
211 | if($filter_key == 'prices') { // price-interval section | 176 | if($filter_key == 'prices') { // price-interval section |
212 | $prices = explode(':', $filter_option); | 177 | $prices = explode(':', $filter_option); |
@@ -221,34 +186,7 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -221,34 +186,7 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
221 | } else { | 186 | } else { |
222 | throw new HttpException(404 ,'Page not found'); | 187 | throw new HttpException(404 ,'Page not found'); |
223 | } | 188 | } |
224 | - | ||
225 | } | 189 | } |
226 | } | 190 | } |
227 | 191 | ||
228 | - | ||
229 | - | ||
230 | - private function parseOldFilter($paths, &$params) { | ||
231 | - $params['filter'] = []; | ||
232 | - $filter_str = substr($paths, 7); | ||
233 | - $filter_options = explode(';', $filter_str); | ||
234 | - foreach ($filter_options as $filter_option) { | ||
235 | - if (empty($filter_option)) { | ||
236 | - continue; | ||
237 | - } | ||
238 | - list($filter_key, $filter_option) = explode('=', $filter_option); | ||
239 | - if($filter_key == 'prices') { // price-interval section | ||
240 | - $prices = explode(':', $filter_option); | ||
241 | - $params['filter'][$filter_key] = [ | ||
242 | - 'min' => floatval($prices[0]), | ||
243 | - 'max' => floatval($prices[1]), | ||
244 | - ]; | ||
245 | - } | ||
246 | - elseif (strpos($filter_key, $this->option_prefix) === 0) { // options section | ||
247 | - $params['filter'][substr($filter_key, 2)] = explode(',', $filter_option); | ||
248 | - } | ||
249 | - else { // brands and other sections | ||
250 | - $params['filter'][$filter_key] = explode(',', $filter_option); | ||
251 | - } | ||
252 | - } | ||
253 | - } | ||
254 | } | 192 | } |
255 | \ No newline at end of file | 193 | \ No newline at end of file |
frontend/widgets/Seo.php
@@ -153,7 +153,7 @@ class Seo extends Widget | @@ -153,7 +153,7 @@ class Seo extends Widget | ||
153 | $title = $this->selectSeoData(self::TITLE); | 153 | $title = $this->selectSeoData(self::TITLE); |
154 | 154 | ||
155 | 155 | ||
156 | - if(!empty($filter) && isset($this->fields['meta-title']) && $title == $this->fields['meta-title']) { | 156 | + if(!empty($filter) && isset($this->fields['meta-title']) && $title == $this->fields['meta-title'] || !empty($filter) && empty($title)) { |
157 | $array = $this->arrayBuilder($filter); | 157 | $array = $this->arrayBuilder($filter); |
158 | 158 | ||
159 | $title_string = $this->getTitleString($array); | 159 | $title_string = $this->getTitleString($array); |
@@ -184,9 +184,13 @@ class Seo extends Widget | @@ -184,9 +184,13 @@ class Seo extends Widget | ||
184 | } else { | 184 | } else { |
185 | 185 | ||
186 | $filter = \Yii::$app->request->get('filters', []); | 186 | $filter = \Yii::$app->request->get('filters', []); |
187 | + | ||
187 | if(!empty($filter)){ | 188 | if(!empty($filter)){ |
188 | $array = $this->arrayBuilder($filter); | 189 | $array = $this->arrayBuilder($filter); |
189 | - return $this->getDescriptionString($array); | 190 | + $this->getView()->registerMetaTag([ |
191 | + 'name' => 'description', | ||
192 | + 'content' => $this->getDescriptionString($array) | ||
193 | + ]); | ||
190 | } | 194 | } |
191 | 195 | ||
192 | } | 196 | } |