0
votes

Opencart generates its sitemap on the fly and this is a problem in a big catalogs over 10.000 products. So I have modified the function to generate a static sitemap in an XML file.

When I access to my http://localhost/index.php?route=extension/feed/google_sitemap I generate a sitemap-google.xml file without problems and with a unlimited execution time.

I tried to add it in a cron in the development server each 4 hours

0 0,4,8,12,16,20 /usr/bin/php /path/to/index.php?route=extension/feed/google_sitemap

But I'm receiving a "command not found".

Can I execute on cli the "?params/etc"?

2

2 Answers

0
votes

You cannot do that, as the URL parameters are only evaluated this way when calling the script over a server. But a quick solution could be to use wget: keep a copy of that sitemap script anywhere under some kind of "secret URL", call it using wget and put the result on your disk.

If you cannot use wget, you could use a PHP script containing file_get_contents. In the same way, it could request the data over a HTTP request and save it in the cached sitemap file.

As a note: if you know which logic should be present to generate that sitemap, you could also write all that logic directly to a PHP script. Running it from shell helps to avoid a blocked server thread, but might be more work

0
votes

https://stackoverflow.com/a/62145786/4843247

You can use following command to generate sitemap.xml:

cd /PATH_TO_YOUR_WWW_ROOT && QUERY_STRING="route=extension/feed/google_sitemap" php -r 'parse_str($_SERVER["QUERY_STRING"],$_GET);include "index.php";' >sitemap.xml.new && mv sitemap.xml.new sitemap.xml