ventesites Posted October 10, 2014 Share Posted October 10, 2014 Hi Using Prestashop 1.6.9 the module sitemap shows : <lastmod>1970-01-01T01:00:00+01:00</lastmod> for a lot of products, not all what can i do to fix this date? Thanks Pat Link to comment Share on other sites More sharing options...
PascalVG Posted October 11, 2014 Share Posted October 11, 2014 Hi Pat, If you get this date, it means the date field is not defined (null). To fix, try this (Didn't test it, but give it a try): edit file /modules/gsitemap/gsitemap.php (Make backup!!!) You have a function: (Example code from PS 1.6.0.8): private function _addSitemapNode($fd, $loc, $priority, $change_freq, $last_mod = null) { fwrite($fd, '<loc>'.(Configuration::get('PS_REWRITING_SETTINGS') ? '<![CDATA['.$loc.']]>' : $loc).'</loc>'."\r\n".'<priority>'."\r\n".number_format($priority, 1, '.', '').'</priority>'."\r\n".($last_mod ? '<lastmod>'.date('c', strtotime($last_mod)).'</lastmod>' : '')."\r\n".'<changefreq>'.$change_freq.'</changefreq>'."\r\n"); } Maybe you can test here to see if the last_mod is null, and if so, use the current time instead: private function _addSitemapNode($fd, $loc, $priority, $change_freq, $last_mod = null) { if (empty($last_mod)) $last_mod ="now"; fwrite($fd, '<loc>'.(Configuration::get('PS_REWRITING_SETTINGS') ? '<![CDATA['.$loc.']]>' : $loc).'</loc>'."\r\n".'<priority>'."\r\n".number_format($priority, 1, '.', '').'</priority>'."\r\n".($last_mod ? '<lastmod>'.date('c', strtotime($last_mod)).'</lastmod>' : '')."\r\n".'<changefreq>'.$change_freq.'</changefreq>'."\r\n"); } (Question remains, how did it stay empty in the first place...) Let me know if it works, pascal. Link to comment Share on other sites More sharing options...
yourtoolcrib Posted July 9, 2015 Share Posted July 9, 2015 Hi Pat, If you get this date, it means the date field is not defined (null). To fix, try this (Didn't test it, but give it a try): edit file /modules/gsitemap/gsitemap.php (Make backup!!!) You have a function: (Example code from PS 1.6.0.8): private function _addSitemapNode($fd, $loc, $priority, $change_freq, $last_mod = null) { fwrite($fd, '<loc>'.(Configuration::get('PS_REWRITING_SETTINGS') ? '<![CDATA['.$loc.']]>' : $loc).'</loc>'."\r\n".'<priority>'."\r\n".number_format($priority, 1, '.', '').'</priority>'."\r\n".($last_mod ? '<lastmod>'.date('c', strtotime($last_mod)).'</lastmod>' : '')."\r\n".'<changefreq>'.$change_freq.'</changefreq>'."\r\n"); } Maybe you can test here to see if the last_mod is null, and if so, use the current time instead: private function _addSitemapNode($fd, $loc, $priority, $change_freq, $last_mod = null) { if (empty($last_mod)) $last_mod ="now"; fwrite($fd, '<loc>'.(Configuration::get('PS_REWRITING_SETTINGS') ? '<![CDATA['.$loc.']]>' : $loc).'</loc>'."\r\n".'<priority>'."\r\n".number_format($priority, 1, '.', '').'</priority>'."\r\n".($last_mod ? '<lastmod>'.date('c', strtotime($last_mod)).'</lastmod>' : '')."\r\n".'<changefreq>'.$change_freq.'</changefreq>'."\r\n"); } (Question remains, how did it stay empty in the first place...) Let me know if it works, pascal. I don't know where to put this "private function _addSitemapNode($fd, $loc, $priority, $change_freq, $last_mod = null) { fwrite($fd, '<loc>'.(Configuration::get('PS_REWRITING_SETTINGS') ? '<![CDATA['.$loc.']]>' : $loc).'</loc>'."\r\n".'<priority>'."\r\n".number_format($priority, 1, '.', '').'</priority>'."\r\n".($last_mod ? '<lastmod>'.date('c', strtotime($last_mod)).'</lastmod>' : '')."\r\n".'<changefreq>'.$change_freq.'</changefreq>'."\r\n"); }" in the file Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now