Commit 315ebf90d3a0104b63fcac9de764294c0800b4e6
1 parent
d57c2c62
sitemap controller fix noindex
Showing
1 changed file
with
73 additions
and
80 deletions
Show diff stats
console/controllers/SiteMapController.php
| @@ -18,6 +18,8 @@ use yii\console\Controller; | @@ -18,6 +18,8 @@ use yii\console\Controller; | ||
| 18 | use yii\web\NotFoundHttpException; | 18 | use yii\web\NotFoundHttpException; |
| 19 | use yii\filters\VerbFilter; | 19 | use yii\filters\VerbFilter; |
| 20 | use developeruz\db_rbac\behaviors\AccessBehavior; | 20 | use developeruz\db_rbac\behaviors\AccessBehavior; |
| 21 | + | ||
| 22 | + | ||
| 21 | /** | 23 | /** |
| 22 | * PageController implements the CRUD actions for Page model. | 24 | * PageController implements the CRUD actions for Page model. |
| 23 | */ | 25 | */ |
| @@ -27,6 +29,20 @@ class SiteMapController extends Controller | @@ -27,6 +29,20 @@ class SiteMapController extends Controller | ||
| 27 | private $urlList = ['http://www.rukzachok.com.ua/']; | 29 | private $urlList = ['http://www.rukzachok.com.ua/']; |
| 28 | private $count = 1; | 30 | private $count = 1; |
| 29 | 31 | ||
| 32 | + public function getAddStatic() { | ||
| 33 | + return [ | ||
| 34 | + 'http://www.rukzachok.com.ua', | ||
| 35 | + 'http://www.rukzachok.com.ua/catalog' | ||
| 36 | + ]; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public function getStaticPages() { | ||
| 40 | + return Page::find()->all(); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public function getCategories() { | ||
| 44 | + return Category::find()->andWhere(['meta_robots' => ''])->all(); | ||
| 45 | + } | ||
| 30 | 46 | ||
| 31 | public function checkFilter($category, $filter) { | 47 | public function checkFilter($category, $filter) { |
| 32 | $productModel = new ProductFrontendSearch(); | 48 | $productModel = new ProductFrontendSearch(); |
| @@ -38,13 +54,6 @@ class SiteMapController extends Controller | @@ -38,13 +54,6 @@ class SiteMapController extends Controller | ||
| 38 | } | 54 | } |
| 39 | } | 55 | } |
| 40 | 56 | ||
| 41 | - public function getAddStatic() { | ||
| 42 | - return [ | ||
| 43 | - 'http://www.rukzachok.com.ua', | ||
| 44 | - 'http://www.rukzachok.com.ua/catalog' | ||
| 45 | - ]; | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | public function getProducts() { | 57 | public function getProducts() { |
| 49 | return Product::find()->all(); | 58 | return Product::find()->all(); |
| 50 | 59 | ||
| @@ -54,14 +63,6 @@ class SiteMapController extends Controller | @@ -54,14 +63,6 @@ class SiteMapController extends Controller | ||
| 54 | return Seo::find()->where(['meta' => ''])->all(); | 63 | return Seo::find()->where(['meta' => ''])->all(); |
| 55 | } | 64 | } |
| 56 | 65 | ||
| 57 | - public function getStaticPages() { | ||
| 58 | - return Page::find()->all(); | ||
| 59 | - } | ||
| 60 | - | ||
| 61 | - public function getCategories() { | ||
| 62 | - return Category::find()->where(['meta_robots' => ''])->all(); | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | public function getArticles() { | 66 | public function getArticles() { |
| 66 | return Articles::find()->all(); | 67 | return Articles::find()->all(); |
| 67 | } | 68 | } |
| @@ -117,8 +118,6 @@ class SiteMapController extends Controller | @@ -117,8 +118,6 @@ class SiteMapController extends Controller | ||
| 117 | 118 | ||
| 118 | Yii::$app->urlManager->addRules($config['components']['urlManager']['rules']); | 119 | Yii::$app->urlManager->addRules($config['components']['urlManager']['rules']); |
| 119 | 120 | ||
| 120 | - | ||
| 121 | - | ||
| 122 | $dirName = Yii::getAlias('@frontend').'/web'; | 121 | $dirName = Yii::getAlias('@frontend').'/web'; |
| 123 | 122 | ||
| 124 | $filename = 'sitemap.xml'; | 123 | $filename = 'sitemap.xml'; |
| @@ -142,69 +141,63 @@ class SiteMapController extends Controller | @@ -142,69 +141,63 @@ class SiteMapController extends Controller | ||
| 142 | $this->createRow($url , 1,$content); | 141 | $this->createRow($url , 1,$content); |
| 143 | } | 142 | } |
| 144 | 143 | ||
| 145 | - | ||
| 146 | - foreach ($this->getProducts() as $product) { | ||
| 147 | - | ||
| 148 | - $url = Url::to(['catalog/product', 'product' => $product]); | ||
| 149 | - $this->createRow($url , 0.9, $content); | ||
| 150 | - } | ||
| 151 | - | ||
| 152 | - | ||
| 153 | - foreach ($this->getArticles() as $article) { | ||
| 154 | - | ||
| 155 | - $url = Url::to(['articles/show', 'translit' => $article->translit, 'id' => $article->id,]); | ||
| 156 | - $this->createRow($url , 0.8,$content); | ||
| 157 | - | ||
| 158 | - } | ||
| 159 | - | ||
| 160 | - | ||
| 161 | - foreach($this->getCategories() as $category) { | ||
| 162 | - foreach ($this->getBrands($category) as $brand) { | ||
| 163 | - if($this->checkFilter($category, ['brands' => [$brand->brand_id]])){ | ||
| 164 | - $url = Url::to(['catalog/category', 'category' => $category, 'filters' => ['brands' => [$brand->alias]]]) ; | ||
| 165 | - $this->createRow($url , 0.8, $content); | ||
| 166 | - } | ||
| 167 | - } | ||
| 168 | - } | ||
| 169 | - | ||
| 170 | - | ||
| 171 | - foreach($this->getCategories() as $category) { | ||
| 172 | - foreach ($this->getFilters($category) as $filter) { | ||
| 173 | - if($this->checkFilter($category, [$filter['group_alias'] => [$filter['option_alias']]])){ | ||
| 174 | - $url = Url::to(['catalog/category', 'category' => $category, 'filters' => [$filter['group_alias'] => [$filter['option_alias']]] ]); | ||
| 175 | - $this->createRow($url , 0.8, $content); | ||
| 176 | - } | ||
| 177 | - | ||
| 178 | - } | ||
| 179 | - } | ||
| 180 | - | ||
| 181 | - foreach($this->getSeoLinks() as $link) { | ||
| 182 | - $url = Yii::$app->urlManager->baseUrl.$link->url; | ||
| 183 | - $this->createRow($url , 0.7, $content); | ||
| 184 | - | ||
| 185 | - } | ||
| 186 | - | ||
| 187 | - | ||
| 188 | - | ||
| 189 | - foreach($this->getCategories() as $category) { | ||
| 190 | - foreach ($this->getFilters($category) as $filter1) { | ||
| 191 | - foreach ($this->getFilters($category) as $filter2) { | ||
| 192 | - if($this->checkFilter($category, [$filter1['group_alias'] => [$filter1['option_alias']],$filter2['group_alias'] => [$filter2['option_alias']]] )){ | ||
| 193 | - $url = Url::to(['catalog/category', 'category' => $category, 'filters' => [$filter1['group_alias'] => [$filter1['option_alias']],$filter2['group_alias'] => [$filter2['option_alias']]] ]); | ||
| 194 | - $this->createRow($url , 0.7, $content); | ||
| 195 | - } | ||
| 196 | - | ||
| 197 | - } | ||
| 198 | - | ||
| 199 | - foreach ($this->getBrands($category) as $brand) { | ||
| 200 | - if($this->checkFilter($category, ['brands' => [$brand->brand_id], $filter1['group_alias'] => [$filter1['option_alias']]] )){ | ||
| 201 | - $url = Url::to(['catalog/category', 'category' => $category, 'filters' => ['brands' => [$brand->alias],$filter1['group_alias'] => [$filter1['option_alias']]]]); | ||
| 202 | - $this->createRow($url , 0.7,$content); | ||
| 203 | - } | ||
| 204 | - | ||
| 205 | - } | ||
| 206 | - } | ||
| 207 | - } | 144 | +// foreach ($this->getProducts() as $product) { |
| 145 | +// | ||
| 146 | +// $url = Url::to(['catalog/product', 'product' => $product]); | ||
| 147 | +// $this->createRow($url , 0.9, $content); | ||
| 148 | +// } | ||
| 149 | +// | ||
| 150 | +// foreach ($this->getArticles() as $article) { | ||
| 151 | +// | ||
| 152 | +// $url = Url::to(['articles/show', 'translit' => $article->translit, 'id' => $article->id,]); | ||
| 153 | +// $this->createRow($url , 0.8,$content); | ||
| 154 | +// | ||
| 155 | +// } | ||
| 156 | +// | ||
| 157 | +// foreach($this->getCategories() as $category) { | ||
| 158 | +// foreach ($this->getBrands($category) as $brand) { | ||
| 159 | +// if($this->checkFilter($category, ['brands' => [$brand->brand_id]])){ | ||
| 160 | +// $url = Url::to(['catalog/category', 'category' => $category, 'filters' => ['brands' => [$brand->alias]]]) ; | ||
| 161 | +// $this->createRow($url , 0.8, $content); | ||
| 162 | +// } | ||
| 163 | +// } | ||
| 164 | +// } | ||
| 165 | +// | ||
| 166 | +// foreach($this->getCategories() as $category) { | ||
| 167 | +// foreach ($this->getFilters($category) as $filter) { | ||
| 168 | +// if($this->checkFilter($category, [$filter['group_alias'] => [$filter['option_alias']]])){ | ||
| 169 | +// $url = Url::to(['catalog/category', 'category' => $category, 'filters' => [$filter['group_alias'] => [$filter['option_alias']]] ]); | ||
| 170 | +// $this->createRow($url , 0.8, $content); | ||
| 171 | +// } | ||
| 172 | +// | ||
| 173 | +// } | ||
| 174 | +// } | ||
| 175 | +// | ||
| 176 | +// foreach($this->getSeoLinks() as $link) { | ||
| 177 | +// $url = Yii::$app->urlManager->baseUrl.$link->url; | ||
| 178 | +// $this->createRow($url , 0.7, $content); | ||
| 179 | +// | ||
| 180 | +// } | ||
| 181 | +// | ||
| 182 | +// foreach($this->getCategories() as $category) { | ||
| 183 | +// foreach ($this->getFilters($category) as $filter1) { | ||
| 184 | +// foreach ($this->getFilters($category) as $filter2) { | ||
| 185 | +// if($this->checkFilter($category, [$filter1['group_alias'] => [$filter1['option_alias']],$filter2['group_alias'] => [$filter2['option_alias']]] )){ | ||
| 186 | +// $url = Url::to(['catalog/category', 'category' => $category, 'filters' => [$filter1['group_alias'] => [$filter1['option_alias']],$filter2['group_alias'] => [$filter2['option_alias']]] ]); | ||
| 187 | +// $this->createRow($url , 0.7, $content); | ||
| 188 | +// } | ||
| 189 | +// | ||
| 190 | +// } | ||
| 191 | +// | ||
| 192 | +// foreach ($this->getBrands($category) as $brand) { | ||
| 193 | +// if($this->checkFilter($category, ['brands' => [$brand->brand_id], $filter1['group_alias'] => [$filter1['option_alias']]] )){ | ||
| 194 | +// $url = Url::to(['catalog/category', 'category' => $category, 'filters' => ['brands' => [$brand->alias],$filter1['group_alias'] => [$filter1['option_alias']]]]); | ||
| 195 | +// $this->createRow($url , 0.7,$content); | ||
| 196 | +// } | ||
| 197 | +// | ||
| 198 | +// } | ||
| 199 | +// } | ||
| 200 | +// } | ||
| 208 | 201 | ||
| 209 | 202 | ||
| 210 | 203 |