I have changed the lastmod format to ('d-m-Y h:i:s') but is still not working? only half of the sitemap feeds have changed?
Please can someone help?
Please can someone help?
In Extensions
Share this post:
Accepted Answer
The code is not showing right here because is not wrapped with code tag so try to implement this one: https://github.com/arastta/arastta/pull/406/files
Responses (33)
-
Accepted Answer
-
Accepted Answer
Hi Bobby, re-due all changes and use following OCMODE script:
<?xml version="1.0" encoding="utf-8"?>
<modification>
<id></id>
<name>Fix-Google-Sitemap</name>
<code>Fix-Google-Sitemap</code>
<version>1</version>
<author>Hermann</author>
<file path="catalog/view/theme/default/template/feed/google_sitemap.tpl">
<operation>
<search><![CDATA[echo $result['date'];]]></search>
<add position="replace"><![CDATA[$datetime = new DateTime($result['date']);
echo $datetime->format('Y-m-d\TH:i:sP');]]></add>
</operation>
<operation>
<search><![CDATA[echo date('Y-m-d H:i:s');]]></search>
<add position="replace"><![CDATA[$datetime = new DateTime(date('Y-m-d'));
echo $datetime->format('Y-m-d\TH:i:sP');]]></add>
</operation>
</file>
</modification> -
Accepted Answer
Bobby here is the solution I've made and work. I've posted the problem long time ago.
Redue all changes you've made to the the source and upload following script n "OCMODE" and click the refresh link at the top:
<?xml version="1.0" encoding="utf-8"?>
<modification>
<id></id>
<name>Fix-Google-Sitemap</name>
<code>Fix-Google-Sitemap</code>
<version>1</version>
<author>Hermann</author>
<file path="catalog/view/theme/default/template/feed/google_sitemap.tpl">
<operation>
<search><![CDATA[echo $result['date'];]]></search>
<add position="replace"><![CDATA[$datetime = new DateTime($result['date']);
echo $datetime->format('Y-m-d\TH:i:sP');]]></add>
</operation>
<operation>
<search><![CDATA[echo date('Y-m-d H:i:s');]]></search>
<add position="replace"><![CDATA[$datetime = new DateTime(date('Y-m-d'));
echo $datetime->format('Y-m-d\TH:i:sP');]]></add>
</operation>
</file>
</modification> -
Accepted Answer
Thank you for your response That looks like it might work, but now i can't see because google cant' fetch pages or retrieve my site map, because of all of this hassle? i now get this message
Network unreachable: robots.txt unreachable We were unable to crawl your Sitemap because we found a robots.txt file at the root of your site but were unable to download it. Please ensure that it is accessible or remove it completely.
but not sure why, it is on the server, my hosting says it is not being blocked? -
Accepted Answer
-
Accepted Answer
-
Accepted Answer
The code in your screenshot works, and the url you posted works.
The code of Aris can not work as it is, if used like this it should be:
<?php if (isset($result['date'])) { ?>
<lastmod><?php echo date('c', strtotime($result['date'])); ?></lastmod>
<?php } else { ?>
<lastmod><?php echo date('c'); ?></lastmod>
<?php } ?>
What you are doing to get it wrong, I have no clue about. That is something you need someone to look at in your system, I guess ... -
Accepted Answer
Sorry guys this is getting confusing? I am not understanding why we are going back and forth on this issue? I have given the code being used, and it is not working on google sitemaps, it comes up with errors?
This is the sitemap that comes with the community software, if it does not work why did they include it? i have not changed anything just added products.
Please can someone just tell me why google says it has errors and what can be done
Thanks -
Accepted Answer
Bobby winters wrote:
Something is not right with that code?
Thanks
Do you try that code above?
As reference, you can check link below
function date php -
Accepted Answer
-
Accepted Answer
-
Accepted Answer
-
Accepted Answer
OK Looking now but it is not what google is saying?
Errors
Invalid date
An invalid date was found. Please fix the date or formatting before resubmitting.
52
Parent tag: url
Tag: lastmod
Value: 2016-04-12 01:26:20
4
Apr 12, 2016
Parent tag: url
Tag: lastmod
Value: 2016-04-12 01:26:20
15
Apr 12, 2016
Parent tag: url
Tag: lastmod
Value: 2016-04-12 01:26:20 -
Accepted Answer
-
Accepted Answer
-
Accepted Answer
-
Accepted Answer
-
Accepted Answer
It's not easy to follow your writings, but you have changed it in /catalog/view/theme/*/template/feed/google_sitemap.tpl - right?
Clock time isn't really needed, Google will accept Y-m-d too, last time I tested I used:
<?php if (isset($result['date'])) { ?>
<lastmod><?php echo date('Y-m-d', strtotime($result['date'])); ?></lastmod>
<?php } else { ?>
<lastmod><?php echo date('Y-m-d'); ?></lastmod>
<?php } ?>
But I guess it could also work with something like (not tested):
<?php if (isset($result['date'])) { ?>
<lastmod><?php echo date('Y-m-d', strtotime($result['date'])) . 'T' . date('H:i:s', strtotime($result['date'])) . '+2.00'; ?></lastmod>
<?php } else { ?>
<lastmod><?php echo date('Y-m-d') . 'T' . date('H:i:s') .'+2.00'; ?></lastmod>
<?php } ?>
BUT, I guess that timezone addition (+2.00) is depending on servers timezone. I would skip it ...
EDIT! Those are the valid formats: https://www.w3.org/TR/NOTE-datetime - but only YYYY-MM-DD is required when using the optional lastmod tag: http://www.sitemaps.org/protocol.html -
Accepted Answer
-
Accepted Answer
Your Reply
Please login to post a reply
You will need to be logged in to be able to post a reply. Login using the form on the right or register an account if you are new here.
Register Here »