diff --git a/app/code/Magento/Sitemap/Model/Sitemap.php b/app/code/Magento/Sitemap/Model/Sitemap.php index f6a5f029eafca2818897c81d75535596598c241d..cad8023bd2794d7f17cab7a82fd3005e3fb16edd 100644 --- a/app/code/Magento/Sitemap/Model/Sitemap.php +++ b/app/code/Magento/Sitemap/Model/Sitemap.php @@ -273,6 +273,7 @@ class Sitemap extends \Magento\Framework\Model\AbstractModel implements \Magento /** @var $helper \Magento\Sitemap\Helper\Data */ $helper = $this->_sitemapData; $storeId = $this->getStoreId(); + $this->_storeManager->setCurrentStore($storeId); $this->addSitemapItem(new DataObject( [ diff --git a/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php b/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php index 83210c5789776a845607c5343e12e85bb31d6d5d..4f55653fad311fef40352cc65b4cb9a94b38f8fc 100644 --- a/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php +++ b/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php @@ -253,6 +253,8 @@ class SitemapTest extends \PHPUnit\Framework\TestCase $expectedWrites, null ); + $this->storeManagerMock->expects($this->once())->method('setCurrentStore')->with(1); + $model->generateXml(); $this->assertCount(count($expectedFile), $actualData, 'Number of generated files is incorrect'); @@ -360,6 +362,8 @@ class SitemapTest extends \PHPUnit\Framework\TestCase $expectedWrites, $robotsInfo ); + $this->storeManagerMock->expects($this->once())->method('setCurrentStore')->with(1); + $model->generateXml(); }