Commit c4adf56b294ec9535fabb9e23d4c8691f5101cb0
1 parent
5e9445d2
big commti
Showing
1 changed file
with
2 additions
and
63 deletions
Show diff stats
common/modules/product/CatalogUrlManager.php
| ... | ... | @@ -15,8 +15,6 @@ use yii\web\UrlRuleInterface; |
| 15 | 15 | |
| 16 | 16 | class CatalogUrlManager implements UrlRuleInterface { |
| 17 | 17 | public $route_map = []; |
| 18 | - | |
| 19 | - public $option_prefix = 'o:'; | |
| 20 | 18 | /** |
| 21 | 19 | * Parses the given request and returns the corresponding route and parameters. |
| 22 | 20 | * @param \yii\web\UrlManager $manager the URL manager |
| ... | ... | @@ -60,24 +58,6 @@ class CatalogUrlManager implements UrlRuleInterface { |
| 60 | 58 | $this->parseFilter($paths[2], $params); |
| 61 | 59 | |
| 62 | 60 | } |
| 63 | - else if(strpos($paths[2], 'filter:') === 0){ | |
| 64 | - $this->parseOldFilter($paths[2], $params); | |
| 65 | - //['catalog/category', 'category' => $category, 'filters' =>$params['filter']] | |
| 66 | - | |
| 67 | - $optionsTemplate = FilterHelper::optionsTemplate(); | |
| 68 | - array_unshift($optionsTemplate, "special", "brands"); | |
| 69 | - $filterView = []; | |
| 70 | - foreach($optionsTemplate as $optionKey){ | |
| 71 | - if(isset($params['filter'][$optionKey])){ | |
| 72 | - $filterView[$optionKey] = $params['filter'][$optionKey]; | |
| 73 | - } | |
| 74 | - | |
| 75 | - | |
| 76 | - } | |
| 77 | - | |
| 78 | - | |
| 79 | - Yii::$app->response->redirect(['catalog/category', 'category' => $category, 'filters' =>$filterView],301); | |
| 80 | - } | |
| 81 | 61 | else { |
| 82 | 62 | throw new HttpException(404 ,'Page not found'); |
| 83 | 63 | } |
| ... | ... | @@ -117,6 +97,7 @@ class CatalogUrlManager implements UrlRuleInterface { |
| 117 | 97 | if (!empty($params['category'])) { |
| 118 | 98 | $category_alias = is_object($params['category']) ? $params['category']->alias : strtolower($params['category']); |
| 119 | 99 | $url = 'catalog/'. $category_alias .'/'; |
| 100 | + unset($params['category']); | |
| 120 | 101 | } else { |
| 121 | 102 | $url = 'catalog/'; |
| 122 | 103 | } |
| ... | ... | @@ -139,6 +120,7 @@ class CatalogUrlManager implements UrlRuleInterface { |
| 139 | 120 | case 'catalog/product': |
| 140 | 121 | if (!empty($params['product'])) { |
| 141 | 122 | $product_alias = is_object($params['product']) ? $params['product']->alias : strtolower($params['product']); |
| 123 | + unset($params['product']); | |
| 142 | 124 | } |
| 143 | 125 | $url = 'product/'. $product_alias; |
| 144 | 126 | |
| ... | ... | @@ -151,23 +133,6 @@ class CatalogUrlManager implements UrlRuleInterface { |
| 151 | 133 | return $url; |
| 152 | 134 | break; |
| 153 | 135 | |
| 154 | -// case 'catalog/brands': | |
| 155 | -// if (empty($params['brand'])) { | |
| 156 | -// return 'brands'; | |
| 157 | -// } else { | |
| 158 | -// | |
| 159 | -// $brand_alias = is_object($params['brand']) ? $params['brand']->alias : strtolower($params['brand']); | |
| 160 | -// } | |
| 161 | -// $url = 'brands/'. $brand_alias .'/'; | |
| 162 | -// | |
| 163 | -// $this->setFilterUrl($params, $url); | |
| 164 | -// | |
| 165 | -// if (!empty($params) && ($query = http_build_query($params)) !== '') { | |
| 166 | -// $url .= '?' . $query; | |
| 167 | -// } | |
| 168 | -// | |
| 169 | -// return $url; | |
| 170 | -// break; | |
| 171 | 136 | } |
| 172 | 137 | } |
| 173 | 138 | |
| ... | ... | @@ -224,30 +189,4 @@ class CatalogUrlManager implements UrlRuleInterface { |
| 224 | 189 | } |
| 225 | 190 | } |
| 226 | 191 | |
| 227 | - | |
| 228 | - | |
| 229 | - private function parseOldFilter($paths, &$params) { | |
| 230 | - $params['filter'] = []; | |
| 231 | - $filter_str = substr($paths, 7); | |
| 232 | - $filter_options = explode(';', $filter_str); | |
| 233 | - foreach ($filter_options as $filter_option) { | |
| 234 | - if (empty($filter_option)) { | |
| 235 | - continue; | |
| 236 | - } | |
| 237 | - list($filter_key, $filter_option) = explode('=', $filter_option); | |
| 238 | - if($filter_key == 'prices') { // price-interval section | |
| 239 | - $prices = explode(':', $filter_option); | |
| 240 | - $params['filter'][$filter_key] = [ | |
| 241 | - 'min' => floatval($prices[0]), | |
| 242 | - 'max' => floatval($prices[1]), | |
| 243 | - ]; | |
| 244 | - } | |
| 245 | - elseif (strpos($filter_key, $this->option_prefix) === 0) { // options section | |
| 246 | - $params['filter'][substr($filter_key, 2)] = explode(',', $filter_option); | |
| 247 | - } | |
| 248 | - else { // brands and other sections | |
| 249 | - $params['filter'][$filter_key] = explode(',', $filter_option); | |
| 250 | - } | |
| 251 | - } | |
| 252 | - } | |
| 253 | 192 | } |
| 254 | 193 | \ No newline at end of file | ... | ... |