Skip to content

Commit 421b879

Browse files
dev
1 parent 0d8dcfa commit 421b879

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

src/controllers/SitemapController.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use skeeks\cms\models\CmsSavedFilter;
1313
use skeeks\cms\models\CmsTree;
1414
use skeeks\cms\models\Tree;
15+
use skeeks\cms\shop\models\ShopBrand;
16+
use skeeks\cms\shop\models\ShopCollection;
1517
use yii\helpers\Url;
1618
use yii\web\Controller;
1719

@@ -34,6 +36,8 @@ public function actionOnRequest()
3436
$this->_addSavedFilters($result);
3537
$this->_addElements($result);
3638
$this->_addAdditional($result);
39+
$this->_addBrands($result);
40+
$this->_addCollections($result);
3741

3842

3943
\Yii::$app->response->format = \yii\web\Response::FORMAT_RAW;
@@ -151,6 +155,66 @@ protected function _addSavedFilters(&$data = [])
151155
return $this;
152156
}
153157

158+
/**
159+
* @param array $data
160+
* @return $this
161+
*/
162+
protected function _addBrands(&$data = [])
163+
{
164+
$q = ShopBrand::find();
165+
166+
if ($q->count()) {
167+
/**
168+
* @var ShopBrand $shopBrand
169+
*/
170+
foreach ($q->each(10) as $shopBrand) {
171+
$tmp = [
172+
"loc" => $shopBrand->absoluteUrl,
173+
"lastmod" => $this->_lastMod($shopBrand),
174+
];
175+
176+
/*if (\Yii::$app->seo->is_sitemap_priority) {
177+
$tmp['priority'] = '0.8';
178+
}*/
179+
180+
$data[] = $tmp;
181+
}
182+
}
183+
184+
185+
return $this;
186+
}
187+
188+
/**
189+
* @param array $data
190+
* @return $this
191+
*/
192+
protected function _addCollections(&$data = [])
193+
{
194+
$q = ShopCollection::find();
195+
196+
if ($q->count()) {
197+
/**
198+
* @var ShopCollection $shopCollection
199+
*/
200+
foreach ($q->each(10) as $shopCollection) {
201+
$tmp = [
202+
"loc" => $shopCollection->absoluteUrl,
203+
"lastmod" => $this->_lastMod($shopCollection),
204+
];
205+
206+
/*if (\Yii::$app->seo->is_sitemap_priority) {
207+
$tmp['priority'] = '0.8';
208+
}*/
209+
210+
$data[] = $tmp;
211+
}
212+
}
213+
214+
215+
return $this;
216+
}
217+
154218
/**
155219
* @param Tree $model
156220
* @return string

0 commit comments

Comments
 (0)