/**
  * Before get sitemap items
  * @param  Sitemap $subject
  * @return void
  */
 public function beforeGetSitemapItems(Sitemap $subject)
 {
     if ($this->_sitemapItemsAdded) {
         return;
     }
     $helper = $this->_sitemapData;
     $storeId = $subject->getStoreId();
     $sitemapItem = new \Magento\Framework\DataObject(['changefreq' => 'weekly', 'priority' => '0.25', 'collection' => $this->_postFactory->create()->getCollection($storeId)]);
     $subject->addSitemapItems($sitemapItem);
     $this->_sitemapItemsAdded = true;
 }
Ejemplo n.º 2
0
 /**
  * Clear sitemap
  *
  * @param \Magento\Sitemap\Model\Sitemap $model
  * @return void
  */
 protected function clearSiteMap(\Magento\Sitemap\Model\Sitemap $model)
 {
     /** @var \Magento\Framework\Filesystem\Directory\Write $directory */
     $directory = $this->_objectManager->get('Magento\\Framework\\Filesystem')->getDirectoryWrite(DirectoryList::ROOT);
     if ($this->getRequest()->getParam('sitemap_id')) {
         $model->load($this->getRequest()->getParam('sitemap_id'));
         $fileName = $model->getSitemapFilename();
         $path = $model->getSitemapPath() . '/' . $fileName;
         if ($fileName && $directory->isFile($path)) {
             $directory->delete($path);
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Initialize sitemap items
  *
  * @return void
  */
 protected function _initSitemapItems()
 {
     parent::_initSitemapItems();
     $this->_sitemapItems[] = new \Magento\Framework\DataObject(['changefreq' => 'weekly', 'priority' => '0.25', 'collection' => \Magento\Framework\App\ObjectManager::getInstance()->create('Magefan\\Blog\\Model\\Category')->getCollection($this->getStoreId())->addStoreFilter($this->getStoreId())->addActiveFilter()]);
     $this->_sitemapItems[] = new \Magento\Framework\DataObject(['changefreq' => 'weekly', 'priority' => '0.25', 'collection' => \Magento\Framework\App\ObjectManager::getInstance()->create('Magefan\\Blog\\Model\\Post')->getCollection($this->getStoreId())->addStoreFilter($this->getStoreId())->addActiveFilter()]);
 }