37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace KupShop\ContentBundle\Sitemap;
|
|
|
|
use KupShop\I18nBundle\Translations\ArticlesTranslation;
|
|
use KupShop\KupShopBundle\Util\StringUtil;
|
|
use Query\Operator;
|
|
use Query\Translation;
|
|
use Symfony\Component\Routing\Router;
|
|
|
|
class ArticleSitemap extends BaseSitemap
|
|
{
|
|
protected static $type = 'articles';
|
|
protected static $module = \Modules::ARTICLES;
|
|
|
|
public function getData(): \Generator
|
|
{
|
|
$articleList = sqlQueryBuilder()
|
|
->select('a.id', 'a.title', 'a.url')
|
|
->from('articles', 'a')
|
|
->where(Translation::coalesceTranslatedFields(ArticlesTranslation::class, ['figure', 'title', 'url']))
|
|
->andWhere(Operator::equals(['a.show_in_search' => 'Y']))
|
|
->andWhere('a.date < NOW()')
|
|
->having('figure="Y"')
|
|
->execute();
|
|
|
|
foreach ($articleList as $article) {
|
|
$url = empty($article['url']) ? StringUtil::slugify($article['title']) : rtrim($article['url'], '/');
|
|
yield [
|
|
'loc' => path('kupshop_content_articles_article_1', ['IDa' => $article['id'], 'slug' => $url], Router::ABSOLUTE_URL),
|
|
'priority' => '0.7',
|
|
'changefreq' => 'monthly',
|
|
];
|
|
}
|
|
}
|
|
}
|