Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Model/Sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function save()
*/
public function getSitemapPath(): string
{
$path = $this->getData('sitemap_path');
$path = (string)$this->getData('sitemap_path');
if ($serverPath = $this->getServerPath()) {
if (!$this->_directory->isDirectory($serverPath)) {
$serverPath = BP . '/' . $serverPath;
Expand Down
40 changes: 28 additions & 12 deletions Plugin/Magento/Sitemap/SitemapPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,40 @@ public function __construct(
public function afterGenerateXml(\Magento\Framework\Model\AbstractModel $sitemap, $result)
{
if ($this->isEnabled($sitemap)) {
/* if ($this->isMageWorxXmlSitemap($sitemap) || !method_exists($sitemap, 'collectSitemapItems')) { */
$sitemapId = $sitemap->getId() ?: 0;
$sitemapId = $sitemap->getId() ?: 0;
if (in_array($sitemapId, $this->generated)) {
return $result;
}
$this->generated[] = $sitemapId;
$this->generated[] = $sitemapId;

$blogSitemap = $this->sitemapFactory->create();
$blogSitemap->setData(
$sitemap->getData()
);
$blogSitemap = $this->sitemapFactory->create();
$blogSitemap->setData(
$sitemap->getData()
);

$blogSitemap->setSitemapFilename(
'blog_' . $sitemap->getSitemapFilename()
);
if (!$blogSitemap->getSitemapId() && $sitemap->getId()) {
$blogSitemap->setSitemapId($sitemap->getId());
}

/* Fix for Amasty\XmlSitemap\Model\Sitemap */
if ($sitemap->getFolderName()) {
$filename = pathinfo($sitemap->getFolderName());
if (!$blogSitemap->getSitemapFilename()) {
if (isset($filename['basename'])) {
$blogSitemap->setSitemapFilename($filename['basename']);
}
}
if (!$blogSitemap->getSitemapPath()) {
if (isset($filename['dirname'])) {
$blogSitemap->setSitemapPath($filename['dirname']);
}
}
}

$blogSitemap->generateXml();
/* } */
$blogSitemap->setSitemapFilename(
'blog_' . $blogSitemap->getSitemapFilename()
);
$blogSitemap->generateXml();
}
return $result;
}
Expand Down
5 changes: 5 additions & 0 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
type="Magefan\Blog\Plugin\Magento\Sitemap\SitemapPlugin" sortOrder="10"/>
</type>

<type name="Amasty\XmlSitemap\Model\Sitemap">
<plugin name="amasty_sitemap_model_sitemap_magefan_blog"
type="Magefan\Blog\Plugin\Magento\Sitemap\SitemapPlugin" sortOrder="10"/>
</type>

<type name="Magento\AdminGws\Model\Models">
<plugin name="magefan_blog_plugin_admingws_model_models_plugin" type="\Magefan\Blog\Plugin\Magento\AdminGws\Model\ModelsPlugin" sortOrder="10"/>
</type>
Expand Down