|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / dev2.destoffenstraat.com / app / code / MageArray / News / Model / |
Filename | /home/dev2.destoffenstraat.com/app/code/MageArray/News/Model/SitemapPlugin.php |
Size | 1.36 kb |
Permission | rwxrwxrwx |
Owner | root : root |
Create time | 17-Aug-2025 10:26 |
Last modified | 06-Apr-2021 18:06 |
Last accessed | 23-Aug-2025 02:07 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
namespace MageArray\News\Model;
use Magento\Framework\DataObject;
use Magento\Sitemap\Helper\Data;
use Magento\Sitemap\Model\Sitemap;
/**
* Class SitemapPlugin
* @package MageArray\News\Model
*/
class SitemapPlugin
{
/**
* @var
*/
protected $_postFactory;
/**
* @var Data
*/
protected $_sitemapData;
/**
* @var bool
*/
protected $_sitemapItemsAdded = false;
/**
* SitemapPlugin constructor.
* @param Data $sitemapData
* @param NewspostFactory $newspostFactory
*/
public function __construct(
Data $sitemapData,
NewspostFactory $newspostFactory
) {
$this->_sitemapData = $sitemapData;
$this->_newspostFactory = $newspostFactory;
}
/**
* @param Sitemap $subject
*/
public function beforeGetSitemapItems(Sitemap $subject)
{
if ($this->_sitemapItemsAdded) {
return;
}
$this->_sitemapData;
$subject->getStoreId();
$sitemapItem = new DataObject(
[
'changefreq' => 'weekly',
'priority' => '0.25',
'collection' => $this->_newspostFactory
->create()->getCollection()->setPostFilter(),
]
);
$subject->addSitemapItems($sitemapItem);
$this->_sitemapItemsAdded = true;
}
}
namespace MageArray\News\Model;
use Magento\Framework\DataObject;
use Magento\Sitemap\Helper\Data;
use Magento\Sitemap\Model\Sitemap;
/**
* Class SitemapPlugin
* @package MageArray\News\Model
*/
class SitemapPlugin
{
/**
* @var
*/
protected $_postFactory;
/**
* @var Data
*/
protected $_sitemapData;
/**
* @var bool
*/
protected $_sitemapItemsAdded = false;
/**
* SitemapPlugin constructor.
* @param Data $sitemapData
* @param NewspostFactory $newspostFactory
*/
public function __construct(
Data $sitemapData,
NewspostFactory $newspostFactory
) {
$this->_sitemapData = $sitemapData;
$this->_newspostFactory = $newspostFactory;
}
/**
* @param Sitemap $subject
*/
public function beforeGetSitemapItems(Sitemap $subject)
{
if ($this->_sitemapItemsAdded) {
return;
}
$this->_sitemapData;
$subject->getStoreId();
$sitemapItem = new DataObject(
[
'changefreq' => 'weekly',
'priority' => '0.25',
'collection' => $this->_newspostFactory
->create()->getCollection()->setPostFilter(),
]
);
$subject->addSitemapItems($sitemapItem);
$this->_sitemapItemsAdded = true;
}
}