Skip to content

Commit

Permalink
magento#10045 backwards compatibility round 2
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrkwiecinski committed Jul 26, 2017
1 parent c4885c9 commit 458d45b
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions app/code/Magento/Sitemap/Model/Sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ protected function _getStream()
* @param DataObject $sitemapItem
* @return $this
* @deprecated
* @see ItemResolverInterface
*/
public function addSitemapItem(DataObject $sitemapItem)
{
Expand All @@ -290,10 +291,37 @@ public function addSitemapItem(DataObject $sitemapItem)
*
* @return void
* @deprecated
* @see ItemResolverInterface
*/
public function collectSitemapItems()
{
/** @var $helper \Magento\Sitemap\Helper\Data */
$helper = $this->_sitemapData;
$storeId = $this->getStoreId();

$this->addSitemapItem(new DataObject(
[
'changefreq' => $helper->getCategoryChangefreq($storeId),
'priority' => $helper->getCategoryPriority($storeId),
'collection' => $this->_categoryFactory->create()->getCollection($storeId),
]
));

$this->addSitemapItem(new DataObject(
[
'changefreq' => $helper->getProductChangefreq($storeId),
'priority' => $helper->getProductPriority($storeId),
'collection' => $this->_productFactory->create()->getCollection($storeId),
]
));

$this->addSitemapItem(new DataObject(
[
'changefreq' => $helper->getPageChangefreq($storeId),
'priority' => $helper->getPagePriority($storeId),
'collection' => $this->_cmsFactory->create()->getCollection($storeId),
]
));
}

/**
Expand All @@ -304,7 +332,6 @@ public function collectSitemapItems()
protected function _initSitemapItems()
{
$sitemapItems = $this->itemResolver->getItems($this->getStoreId());
$this->collectSitemapItems();
$mappedItems = $this->mapToSitemapItem();
$this->_sitemapItems = array_merge($sitemapItems, $mappedItems);

Expand Down Expand Up @@ -791,7 +818,7 @@ private function mapToSitemapItem()
$items = [];

foreach ($this->_sitemapItems as $data) {
foreach($data->getCollection() as $item) {
foreach ($data->getCollection() as $item) {
$items[] = $this->sitemapItemFactory->create([
'url' => $item->getUrl(),
'updatedAt' => $item->getUpdatedAt(),
Expand Down

0 comments on commit 458d45b

Please sign in to comment.