Post by Cue4cheap » Fri Feb 07, 2025 8:54 am

Ahmed-E-Shop wrote:
Thu Feb 06, 2025 9:15 pm

So let me clarify : Can this line :

Code: Select all

 RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L] 
be replaced with this line :

Code: Select all

 curl https://domain.com.au/index.php?route=extension/feed/google_sitemap  > /home/user/public_html/sitemap.xml 
in the .htaccess file ?
No it can't. That curl command goes as your cron command.

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by nonnedelectari » Fri Feb 07, 2025 8:59 am

Ahmed-E-Shop wrote:
Thu Feb 06, 2025 9:15 pm
nonnedelectari wrote:
Thu Feb 06, 2025 9:22 am
Ahmed-E-Shop wrote:
Thu Feb 06, 2025 4:02 am


I would Like to generate sitemap.xml ( OC 3.0.4.0 )
Can you help me ?
Where can I add or execute this code to create the file ?
Thanks
You do not need to create a sitemap.xml file, that is what this, in htaccess, is for:

Code: Select all

RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
just submit the sitemap as /sitemap.xml and that htaccess line will translate it to the extension and send out the generated sitemap.
If the generation is too slow, you could always cache the output.
Yes, it is clear to me that the problem is not in creating the file itself. According to my understanding from the colleagues' words, it is finding a way to create the file smoothly to speed up the archiving process.

So let me clarify : Can this line :

Code: Select all

 RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L] 
be replaced with this line :

Code: Select all

 curl https://domain.com.au/index.php?route=extension/feed/google_sitemap  > /home/user/public_html/sitemap.xml 
in the .htaccess file ?

In considration this is ( /home/user ) a { Rootname }

Is this a practical result of the serious discussions that took place here ? ( Expert may tell us )
No, you cannot use curl in htaccess.

You can just cache the sitemaps using the standard cache functionality:

in catalog/controller/extension/feed/google_sitemap.php

add this:

Code: Select all

			// enable cache, set the cache file and try to read it
			$cache = true;
			$cache_file = 'sitemap-google';
			$output = false;
			if ($cache) $output = $this->cache->get($cache_file);
			if ($output === false) {
after this:

Code: Select all

if ($this->config->get('feed_google_sitemap_status')) {
add this:

Code: Select all

			// write the cache file if cache enabled
			if ($cache) $this->cache->set($cache_file,$output);
			}
after this:

Code: Select all

$output .= '</urlset>';
That way the sitemap is cached and delivered from the cache until it expires or you delete the cache file.

Active Member

Posts

Joined
Thu Mar 04, 2021 6:34 pm

Post by paulfeakins » Fri Feb 07, 2025 7:03 pm

Ahmed-E-Shop wrote:
Thu Feb 06, 2025 9:15 pm
Is this a practical result of the serious discussions that took place here ? ( Expert may tell us )
Yes, but this has already been described above.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by Ahmed-E-Shop » Sat Feb 08, 2025 2:39 am

Thanks. Cue4cheap
Thanks, nonnedelectari, for this nice extra code.
Thanks, paulfeakins (How can I do this automatically is what was not clear to me?) I read about cron jobs, and now it is completely obvious to me.

New member

Posts

Joined
Mon Nov 11, 2024 7:40 pm
Who is online

Users browsing this forum: No registered users and 9 guests