/**
  * 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;
 }
Exemplo n.º 2
0
 /**
  * Initialize sitemap items
  *
  * @return void
  */
 protected function _initSitemapItems()
 {
     /** @var $helper \Magento\Sitemap\Helper\Data */
     $helper = $this->_sitemapData;
     $storeId = $this->getStoreId();
     $this->_sitemapItems[] = new \Magento\Framework\DataObject(['changefreq' => $helper->getCategoryChangefreq($storeId), 'priority' => $helper->getCategoryPriority($storeId), 'collection' => $this->_categoryFactory->create()->getCollection($storeId)]);
     $this->_sitemapItems[] = new \Magento\Framework\DataObject(['changefreq' => $helper->getProductChangefreq($storeId), 'priority' => $helper->getProductPriority($storeId), 'collection' => $this->_productFactory->create()->getCollection($storeId)]);
     $this->_sitemapItems[] = new \Magento\Framework\DataObject(['changefreq' => $helper->getPageChangefreq($storeId), 'priority' => $helper->getPagePriority($storeId), 'collection' => $this->_cmsFactory->create()->getCollection($storeId)]);
     $this->_tags = [self::TYPE_INDEX => [self::OPEN_TAG_KEY => '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL . '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL, self::CLOSE_TAG_KEY => '</sitemapindex>'], self::TYPE_URL => [self::OPEN_TAG_KEY => '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"' . ' xmlns:content="http://www.google.com/schemas/sitemap-content/1.0"' . ' xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">' . PHP_EOL, self::CLOSE_TAG_KEY => '</urlset>']];
 }