Skip to content

Commit eaeb556

Browse files
authored
Update Sitemap.php
1 parent 401c7a3 commit eaeb556

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

Model/Sitemap.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Magento\Framework\App\ProductMetadataInterface;
1212
use Magefan\Blog\Api\SitemapConfigInterface;
13+
use Magento\Store\Model\ScopeInterface;
1314

1415
/**
1516
* Deprecated
@@ -32,6 +33,26 @@ protected function _initSitemapItems()
3233

3334
$sitemapItems = [];
3435
if ($sitemapConfig->isEnabledSitemap(SitemapConfigInterface::HOME_PAGE)) {
36+
37+
$url = $objectManager->get(\Magefan\Blog\Model\Url::class)->getBasePath();
38+
39+
$scopeConfig = $objectManager->get(\Magento\Framework\App\Config\ScopeConfigInterface::class);
40+
$advancedPermalinkEnabled = $scopeConfig->getValue(
41+
Config::XML_PATH_ADVANCED_PERMALINK_ENABLED,
42+
ScopeInterface::SCOPE_STORE
43+
);
44+
45+
if (!$advancedPermalinkEnabled) {
46+
$redirectToNoSlash = $scopeConfig->getValue(
47+
Config::XML_PATH_REDIRECT_TO_NO_SLASH,
48+
ScopeInterface::SCOPE_STORE
49+
);
50+
51+
if (!$redirectToNoSlash) {
52+
$url = trim($url, '/') . '/';
53+
}
54+
}
55+
3556
$sitemapItems[] = new \Magento\Framework\DataObject(
3657
[
3758
'changefreq' => $sitemapConfig->getFrequency(SitemapConfigInterface::HOME_PAGE),
@@ -43,7 +64,7 @@ protected function _initSitemapItems()
4364
\Magento\Framework\DataObject::class
4465
)->setData([
4566
'updated_at' => '',
46-
'url' => $objectManager->get(\Magefan\Blog\Model\Url::class)->getBasePath(),
67+
'url' => $url,
4768
])
4869
)
4970
]

0 commit comments

Comments
 (0)