Commit ea07e7cb369f25e294b85f3c432f1fb6faa6ce0e
1 parent
0deff972
canonical update2.0
Showing
3 changed files
with
9 additions
and
3 deletions
Show diff stats
common/modules/product/CatalogUrlManager.php
... | ... | @@ -102,6 +102,8 @@ class CatalogUrlManager implements UrlRuleInterface { |
102 | 102 | public function createUrl($manager, $route, $params) |
103 | 103 | { |
104 | 104 | |
105 | + | |
106 | + | |
105 | 107 | if (!in_array($route, $this->route_map)) { |
106 | 108 | return false; |
107 | 109 | } |
... | ... | @@ -131,10 +133,13 @@ class CatalogUrlManager implements UrlRuleInterface { |
131 | 133 | break; |
132 | 134 | |
133 | 135 | case 'catalog/product': |
136 | + | |
134 | 137 | if (!empty($params['product'])) { |
135 | 138 | $product_alias = is_object($params['product']) ? $params['product']->alias : strtolower($params['product']); |
139 | + $url = 'product/'. $product_alias; | |
140 | + } else { | |
141 | + $url = 'product/'; | |
136 | 142 | } |
137 | - $url = 'product/'. $product_alias; | |
138 | 143 | |
139 | 144 | if (!empty($params) && ($query = http_build_query($params)) !== '') { |
140 | 145 | $url .= '?' . $query; | ... | ... |
frontend/config/main.php
frontend/views/layouts/main.php
... | ... | @@ -78,8 +78,8 @@ $this->registerJs(" |
78 | 78 | <title><?= Seo::widget([ 'row'=>'title'])?></title> |
79 | 79 | <?= Seo::widget([ 'row'=>'description'])?> |
80 | 80 | <?= Seo::widget([ 'row'=>'meta'])?> |
81 | - <?= $this->registerLinkTag(['rel' => 'canonical', 'href' => Url::canonical()]); ?> | |
82 | - <link rel="shortcut icon" href="<?= Yii::$app->request->baseUrl ?>/img/favicon.ico" type="image/x-icon"/> | |
81 | + <?php $this->registerLinkTag(['rel' => 'canonical', 'href' => Yii::$app->urlManager->baseUrl.Yii::$app->request->url ]); ?> | |
82 | + <link rel="shortcut icon" href="<?= Yii::$app->urlManager->baseUrl ?>/img/favicon.ico" type="image/x-icon"/> | |
83 | 83 | <?php $this->head () ?> |
84 | 84 | |
85 | 85 | <!-- SOCIAL ICON --> | ... | ... |