diff --git a/console/controllers/SiteMapController.php b/console/controllers/SiteMapController.php index ce36756..db60556 100644 --- a/console/controllers/SiteMapController.php +++ b/console/controllers/SiteMapController.php @@ -18,6 +18,8 @@ use yii\console\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; use developeruz\db_rbac\behaviors\AccessBehavior; + + /** * PageController implements the CRUD actions for Page model. */ @@ -27,6 +29,20 @@ class SiteMapController extends Controller private $urlList = ['http://www.rukzachok.com.ua/']; private $count = 1; + public function getAddStatic() { + return [ + 'http://www.rukzachok.com.ua', + 'http://www.rukzachok.com.ua/catalog' + ]; + } + + public function getStaticPages() { + return Page::find()->all(); + } + + public function getCategories() { + return Category::find()->andWhere(['meta_robots' => ''])->all(); + } public function checkFilter($category, $filter) { $productModel = new ProductFrontendSearch(); @@ -38,13 +54,6 @@ class SiteMapController extends Controller } } - public function getAddStatic() { - return [ - 'http://www.rukzachok.com.ua', - 'http://www.rukzachok.com.ua/catalog' - ]; - } - public function getProducts() { return Product::find()->all(); @@ -54,14 +63,6 @@ class SiteMapController extends Controller return Seo::find()->where(['meta' => ''])->all(); } - public function getStaticPages() { - return Page::find()->all(); - } - - public function getCategories() { - return Category::find()->where(['meta_robots' => ''])->all(); - } - public function getArticles() { return Articles::find()->all(); } @@ -117,8 +118,6 @@ class SiteMapController extends Controller Yii::$app->urlManager->addRules($config['components']['urlManager']['rules']); - - $dirName = Yii::getAlias('@frontend').'/web'; $filename = 'sitemap.xml'; @@ -142,69 +141,63 @@ class SiteMapController extends Controller $this->createRow($url , 1,$content); } - - foreach ($this->getProducts() as $product) { - - $url = Url::to(['catalog/product', 'product' => $product]); - $this->createRow($url , 0.9, $content); - } - - - foreach ($this->getArticles() as $article) { - - $url = Url::to(['articles/show', 'translit' => $article->translit, 'id' => $article->id,]); - $this->createRow($url , 0.8,$content); - - } - - - foreach($this->getCategories() as $category) { - foreach ($this->getBrands($category) as $brand) { - if($this->checkFilter($category, ['brands' => [$brand->brand_id]])){ - $url = Url::to(['catalog/category', 'category' => $category, 'filters' => ['brands' => [$brand->alias]]]) ; - $this->createRow($url , 0.8, $content); - } - } - } - - - foreach($this->getCategories() as $category) { - foreach ($this->getFilters($category) as $filter) { - if($this->checkFilter($category, [$filter['group_alias'] => [$filter['option_alias']]])){ - $url = Url::to(['catalog/category', 'category' => $category, 'filters' => [$filter['group_alias'] => [$filter['option_alias']]] ]); - $this->createRow($url , 0.8, $content); - } - - } - } - - foreach($this->getSeoLinks() as $link) { - $url = Yii::$app->urlManager->baseUrl.$link->url; - $this->createRow($url , 0.7, $content); - - } - - - - foreach($this->getCategories() as $category) { - foreach ($this->getFilters($category) as $filter1) { - foreach ($this->getFilters($category) as $filter2) { - if($this->checkFilter($category, [$filter1['group_alias'] => [$filter1['option_alias']],$filter2['group_alias'] => [$filter2['option_alias']]] )){ - $url = Url::to(['catalog/category', 'category' => $category, 'filters' => [$filter1['group_alias'] => [$filter1['option_alias']],$filter2['group_alias'] => [$filter2['option_alias']]] ]); - $this->createRow($url , 0.7, $content); - } - - } - - foreach ($this->getBrands($category) as $brand) { - if($this->checkFilter($category, ['brands' => [$brand->brand_id], $filter1['group_alias'] => [$filter1['option_alias']]] )){ - $url = Url::to(['catalog/category', 'category' => $category, 'filters' => ['brands' => [$brand->alias],$filter1['group_alias'] => [$filter1['option_alias']]]]); - $this->createRow($url , 0.7,$content); - } - - } - } - } +// foreach ($this->getProducts() as $product) { +// +// $url = Url::to(['catalog/product', 'product' => $product]); +// $this->createRow($url , 0.9, $content); +// } +// +// foreach ($this->getArticles() as $article) { +// +// $url = Url::to(['articles/show', 'translit' => $article->translit, 'id' => $article->id,]); +// $this->createRow($url , 0.8,$content); +// +// } +// +// foreach($this->getCategories() as $category) { +// foreach ($this->getBrands($category) as $brand) { +// if($this->checkFilter($category, ['brands' => [$brand->brand_id]])){ +// $url = Url::to(['catalog/category', 'category' => $category, 'filters' => ['brands' => [$brand->alias]]]) ; +// $this->createRow($url , 0.8, $content); +// } +// } +// } +// +// foreach($this->getCategories() as $category) { +// foreach ($this->getFilters($category) as $filter) { +// if($this->checkFilter($category, [$filter['group_alias'] => [$filter['option_alias']]])){ +// $url = Url::to(['catalog/category', 'category' => $category, 'filters' => [$filter['group_alias'] => [$filter['option_alias']]] ]); +// $this->createRow($url , 0.8, $content); +// } +// +// } +// } +// +// foreach($this->getSeoLinks() as $link) { +// $url = Yii::$app->urlManager->baseUrl.$link->url; +// $this->createRow($url , 0.7, $content); +// +// } +// +// foreach($this->getCategories() as $category) { +// foreach ($this->getFilters($category) as $filter1) { +// foreach ($this->getFilters($category) as $filter2) { +// if($this->checkFilter($category, [$filter1['group_alias'] => [$filter1['option_alias']],$filter2['group_alias'] => [$filter2['option_alias']]] )){ +// $url = Url::to(['catalog/category', 'category' => $category, 'filters' => [$filter1['group_alias'] => [$filter1['option_alias']],$filter2['group_alias'] => [$filter2['option_alias']]] ]); +// $this->createRow($url , 0.7, $content); +// } +// +// } +// +// foreach ($this->getBrands($category) as $brand) { +// if($this->checkFilter($category, ['brands' => [$brand->brand_id], $filter1['group_alias'] => [$filter1['option_alias']]] )){ +// $url = Url::to(['catalog/category', 'category' => $category, 'filters' => ['brands' => [$brand->alias],$filter1['group_alias'] => [$filter1['option_alias']]]]); +// $this->createRow($url , 0.7,$content); +// } +// +// } +// } +// } -- libgit2 0.21.4