File tree Expand file tree Collapse file tree 4 files changed +20
-4
lines changed Expand file tree Collapse file tree 4 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,11 @@ class Sitemap extends \Magento\Framework\Model\AbstractModel implements \Magento
43
43
44
44
const TYPE_URL = 'url ' ;
45
45
46
+ /**
47
+ * Last mode date min value
48
+ */
49
+ const LAST_MOD_MIN_VAL = '0000-01-01 00:00:00 ' ;
50
+
46
51
/**
47
52
* Real file path
48
53
*
@@ -157,6 +162,13 @@ class Sitemap extends \Magento\Framework\Model\AbstractModel implements \Magento
157
162
*/
158
163
protected $ _cacheTag = true ;
159
164
165
+ /**
166
+ * Last mode min timestamp value
167
+ *
168
+ * @var int
169
+ */
170
+ private $ lastModMinTsVal ;
171
+
160
172
/**
161
173
* Initialize dependencies.
162
174
*
@@ -661,7 +673,11 @@ protected function _getMediaUrl($url)
661
673
*/
662
674
protected function _getFormattedLastmodDate ($ date )
663
675
{
664
- return date ('c ' , strtotime ($ date ));
676
+ if ($ this ->lastModMinTsVal === null ) {
677
+ $ this ->lastModMinTsVal = strtotime (self ::LAST_MOD_MIN_VAL );
678
+ }
679
+ $ timestamp = max (strtotime ($ date ), $ this ->lastModMinTsVal );
680
+ return date ('c ' , $ timestamp );
665
681
}
666
682
667
683
/**
Original file line number Diff line number Diff line change @@ -540,7 +540,7 @@ protected function _getModelMock($mockBeforeSave = false)
540
540
$ this ->returnValue (
541
541
[
542
542
new \Magento \Framework \DataObject (
543
- ['url ' => 'product.html ' , 'updated_at ' => '2012-12-21 00:00:00 ' ]
543
+ ['url ' => 'product.html ' , 'updated_at ' => '0000-00-00 00:00:00 ' ]
544
544
),
545
545
new \Magento \Framework \DataObject (
546
546
[
Original file line number Diff line number Diff line change 10
10
xmlns : image =" http://www.google.com/schemas/sitemap-image/1.1" >
11
11
<url >
12
12
<loc >http://store.com/product.html</loc >
13
- <lastmod >2012-12-21T00 :00:00-08:00</lastmod >
13
+ <lastmod >0000-01-01T00 :00:00-08:00</lastmod >
14
14
<changefreq >monthly</changefreq >
15
15
<priority >0.5</priority >
16
16
</url >
Original file line number Diff line number Diff line change 22
22
</url >
23
23
<url >
24
24
<loc >http://store.com/product.html</loc >
25
- <lastmod >2012-12-21T00 :00:00-08:00</lastmod >
25
+ <lastmod >0000-01-01T00 :00:00-08:00</lastmod >
26
26
<changefreq >monthly</changefreq >
27
27
<priority >0.5</priority >
28
28
</url >
You can’t perform that action at this time.
0 commit comments