Commit d57c2c6265e7b3790fc188be27db487894af323e
1 parent
f703530f
sitemap controller fix noindex
Showing
1 changed file
with
14 additions
and
16 deletions
Show diff stats
console/controllers/SiteMapController.php
| ... | ... | @@ -28,7 +28,7 @@ class SiteMapController extends Controller |
| 28 | 28 | private $count = 1; |
| 29 | 29 | |
| 30 | 30 | |
| 31 | - public function checkFilter($category, $filter){ | |
| 31 | + public function checkFilter($category, $filter) { | |
| 32 | 32 | $productModel = new ProductFrontendSearch(); |
| 33 | 33 | $productProvider = $productModel->search($category, $filter); |
| 34 | 34 | if(!empty($productProvider->models)){ |
| ... | ... | @@ -38,7 +38,7 @@ class SiteMapController extends Controller |
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function getAddStatic(){ | |
| 41 | + public function getAddStatic() { | |
| 42 | 42 | return [ |
| 43 | 43 | 'http://www.rukzachok.com.ua', |
| 44 | 44 | 'http://www.rukzachok.com.ua/catalog' |
| ... | ... | @@ -52,22 +52,21 @@ class SiteMapController extends Controller |
| 52 | 52 | |
| 53 | 53 | public function getSeoLinks() { |
| 54 | 54 | return Seo::find()->where(['meta' => ''])->all(); |
| 55 | - | |
| 56 | 55 | } |
| 57 | 56 | |
| 58 | - public function getStaticPages(){ | |
| 57 | + public function getStaticPages() { | |
| 59 | 58 | return Page::find()->all(); |
| 60 | 59 | } |
| 61 | 60 | |
| 62 | - public function getCategories(){ | |
| 63 | - return Category::find()->all(); | |
| 61 | + public function getCategories() { | |
| 62 | + return Category::find()->where(['meta_robots' => ''])->all(); | |
| 64 | 63 | } |
| 65 | 64 | |
| 66 | - public function getArticles(){ | |
| 65 | + public function getArticles() { | |
| 67 | 66 | return Articles::find()->all(); |
| 68 | 67 | } |
| 69 | 68 | |
| 70 | - public function getBrands($category){ | |
| 69 | + public function getBrands($category) { | |
| 71 | 70 | |
| 72 | 71 | return $category->brands; |
| 73 | 72 | } |
| ... | ... | @@ -76,14 +75,13 @@ class SiteMapController extends Controller |
| 76 | 75 | * @param $category Category; |
| 77 | 76 | * @return mixed |
| 78 | 77 | */ |
| 79 | - | |
| 80 | - public function getFilters($category){ | |
| 78 | + public function getFilters($category) { | |
| 81 | 79 | |
| 82 | 80 | return $category->getActiveFilters()->all(); |
| 83 | 81 | |
| 84 | 82 | } |
| 85 | 83 | |
| 86 | - public function checkUrl($url){ | |
| 84 | + public function checkUrl($url) { | |
| 87 | 85 | |
| 88 | 86 | if (preg_match('/filters:[^=]+=[^=]+;[^=]+=[^=]+/', $url)) { |
| 89 | 87 | $reverse_url = preg_replace('/filters:([^=]+=[^=]+);([^=]+=[^=]+)/', 'filters:$2;$1', $url); |
| ... | ... | @@ -97,7 +95,7 @@ class SiteMapController extends Controller |
| 97 | 95 | } |
| 98 | 96 | } |
| 99 | 97 | |
| 100 | - public function createRow( $url, $priority, &$content ){ | |
| 98 | + public function createRow( $url, $priority, &$content ) { | |
| 101 | 99 | if($this->checkUrl($url)){ |
| 102 | 100 | print $this->count++ . "\n"; |
| 103 | 101 | $content .= '<url>' . |
| ... | ... | @@ -160,7 +158,7 @@ class SiteMapController extends Controller |
| 160 | 158 | } |
| 161 | 159 | |
| 162 | 160 | |
| 163 | - foreach($this->getCategories() as $category){ | |
| 161 | + foreach($this->getCategories() as $category) { | |
| 164 | 162 | foreach ($this->getBrands($category) as $brand) { |
| 165 | 163 | if($this->checkFilter($category, ['brands' => [$brand->brand_id]])){ |
| 166 | 164 | $url = Url::to(['catalog/category', 'category' => $category, 'filters' => ['brands' => [$brand->alias]]]) ; |
| ... | ... | @@ -170,7 +168,7 @@ class SiteMapController extends Controller |
| 170 | 168 | } |
| 171 | 169 | |
| 172 | 170 | |
| 173 | - foreach($this->getCategories() as $category){ | |
| 171 | + foreach($this->getCategories() as $category) { | |
| 174 | 172 | foreach ($this->getFilters($category) as $filter) { |
| 175 | 173 | if($this->checkFilter($category, [$filter['group_alias'] => [$filter['option_alias']]])){ |
| 176 | 174 | $url = Url::to(['catalog/category', 'category' => $category, 'filters' => [$filter['group_alias'] => [$filter['option_alias']]] ]); |
| ... | ... | @@ -180,7 +178,7 @@ class SiteMapController extends Controller |
| 180 | 178 | } |
| 181 | 179 | } |
| 182 | 180 | |
| 183 | - foreach($this->getSeoLinks() as $link){ | |
| 181 | + foreach($this->getSeoLinks() as $link) { | |
| 184 | 182 | $url = Yii::$app->urlManager->baseUrl.$link->url; |
| 185 | 183 | $this->createRow($url , 0.7, $content); |
| 186 | 184 | |
| ... | ... | @@ -188,7 +186,7 @@ class SiteMapController extends Controller |
| 188 | 186 | |
| 189 | 187 | |
| 190 | 188 | |
| 191 | - foreach($this->getCategories() as $category){ | |
| 189 | + foreach($this->getCategories() as $category) { | |
| 192 | 190 | foreach ($this->getFilters($category) as $filter1) { |
| 193 | 191 | foreach ($this->getFilters($category) as $filter2) { |
| 194 | 192 | if($this->checkFilter($category, [$filter1['group_alias'] => [$filter1['option_alias']],$filter2['group_alias'] => [$filter2['option_alias']]] )){ | ... | ... |