Sitemap.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Copyright © 2016 Ihor Vansach (ihor@magefan.com). All rights reserved.
  4. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
  5. *
  6. * Glory to Ukraine! Glory to the heroes!
  7. */
  8. namespace Magefan\Blog\Model;
  9. /**
  10. * Overide sitemap
  11. */
  12. class Sitemap extends \Magento\Sitemap\Model\Sitemap
  13. {
  14. /**
  15. * Initialize sitemap items
  16. *
  17. * @return void
  18. */
  19. protected function _initSitemapItems()
  20. {
  21. parent::_initSitemapItems();
  22. $this->_sitemapItems = [];
  23. $this->_sitemapItems[] = new \Magento\Framework\DataObject(
  24. [
  25. 'changefreq' => 'weekly',
  26. 'priority' => '0.25',
  27. 'collection' => \Magento\Framework\App\ObjectManager::getInstance()->create(
  28. 'Magefan\Blog\Model\Category'
  29. )->getCollection($this->getStoreId())
  30. ->addStoreFilter($this->getStoreId())
  31. ->addActiveFilter(),
  32. ]
  33. );
  34. $this->_sitemapItems[] = new \Magento\Framework\DataObject(
  35. [
  36. 'changefreq' => 'weekly',
  37. 'priority' => '0.25',
  38. 'collection' => \Magento\Framework\App\ObjectManager::getInstance()->create(
  39. 'Magefan\Blog\Model\Post'
  40. )->getCollection($this->getStoreId())
  41. ->addStoreFilter($this->getStoreId())
  42. ->addActiveFilter(),
  43. ]
  44. );
  45. }
  46. /**
  47. * Disable save action
  48. * @return sekf
  49. */
  50. public function save()
  51. {
  52. return $this;
  53. }
  54. }