/* List all product and category URLs for an OpenCart website using the standard Google Sitemap feed */
<?php
$domain = "https://www.example.com/" ; // Replace with your actual domain name
$base = "index.php?route=feed/google_sitemap" ;
$reqURL = $domain . $base ;
$html = @file_get_contents ($reqURL) ;
if($html === FALSE)
{
echo '<h1>Please make sure that Google Sitemap Feed is active and the URL is correct</h1>' ;
die();
}
$DOM = new DOMDocument() ;
$DOM->loadHTML($html) ;
/* Filter loc tags */
$rows = $DOM->getElementsByTagName("loc") ;
$i = 0 ;
echo "<pre>\n" ;
while(is_object($url = $DOM->getElementsByTagName("url")->item($i)))
{
foreach($url->childNodes as $url)
{
if($url->nodeName=='loc')
{
echo $url->nodeValue . PHP_EOL ;
}
}
$i++ ;
}
echo "</pre>\n" ;
Comments