diff --git a/app/code/Magento/Sitemap/Model/Sitemap.php b/app/code/Magento/Sitemap/Model/Sitemap.php
index 515caebe1ef27..f6a5f029eafca 100644
--- a/app/code/Magento/Sitemap/Model/Sitemap.php
+++ b/app/code/Magento/Sitemap/Model/Sitemap.php
@@ -43,6 +43,11 @@ class Sitemap extends \Magento\Framework\Model\AbstractModel implements \Magento
const TYPE_URL = 'url';
+ /**
+ * Last mode date min value
+ */
+ const LAST_MOD_MIN_VAL = '0000-01-01 00:00:00';
+
/**
* Real file path
*
@@ -157,6 +162,13 @@ class Sitemap extends \Magento\Framework\Model\AbstractModel implements \Magento
*/
protected $_cacheTag = true;
+ /**
+ * Last mode min timestamp value
+ *
+ * @var int
+ */
+ private $lastModMinTsVal;
+
/**
* Initialize dependencies.
*
@@ -661,7 +673,11 @@ protected function _getMediaUrl($url)
*/
protected function _getFormattedLastmodDate($date)
{
- return date('c', strtotime($date));
+ if ($this->lastModMinTsVal === null) {
+ $this->lastModMinTsVal = strtotime(self::LAST_MOD_MIN_VAL);
+ }
+ $timestamp = max(strtotime($date), $this->lastModMinTsVal);
+ return date('c', $timestamp);
}
/**
diff --git a/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php b/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php
index 40b72cbd53c00..83210c5789776 100644
--- a/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php
+++ b/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php
@@ -540,7 +540,7 @@ protected function _getModelMock($mockBeforeSave = false)
$this->returnValue(
[
new \Magento\Framework\DataObject(
- ['url' => 'product.html', 'updated_at' => '2012-12-21 00:00:00']
+ ['url' => 'product.html', 'updated_at' => '0000-00-00 00:00:00']
),
new \Magento\Framework\DataObject(
[
diff --git a/app/code/Magento/Sitemap/Test/Unit/Model/_files/sitemap-1-3.xml b/app/code/Magento/Sitemap/Test/Unit/Model/_files/sitemap-1-3.xml
index 3a0357cf30c51..519464cf76cf1 100644
--- a/app/code/Magento/Sitemap/Test/Unit/Model/_files/sitemap-1-3.xml
+++ b/app/code/Magento/Sitemap/Test/Unit/Model/_files/sitemap-1-3.xml
@@ -10,7 +10,7 @@
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
http://store.com/product.html
- 2012-12-21T00:00:00-08:00
+ 0000-01-01T00:00:00-08:00
monthly
0.5
diff --git a/app/code/Magento/Sitemap/Test/Unit/Model/_files/sitemap-single.xml b/app/code/Magento/Sitemap/Test/Unit/Model/_files/sitemap-single.xml
index e79e022c98995..cc2ff96dd28f2 100644
--- a/app/code/Magento/Sitemap/Test/Unit/Model/_files/sitemap-single.xml
+++ b/app/code/Magento/Sitemap/Test/Unit/Model/_files/sitemap-single.xml
@@ -22,7 +22,7 @@
http://store.com/product.html
- 2012-12-21T00:00:00-08:00
+ 0000-01-01T00:00:00-08:00
monthly
0.5