jdice Posted October 20, 2009 Posted October 20, 2009 Hi...I uploaded googlesitemap generator by bobby about a year ago. It only has two files...googlesitemapcategories.php & googlesitemapproducts.php. Then I go to google.com/webmasters/sitemaps and put my website in. However, the googlesitecategories.php is fine but googlesitemapproducts.php is not. Google is giving me this error: 1193 Invalid date An invalid date was found. Please fix the date or formatting before resubmitting....FOR MY googlesitemapproducts.php page. does anyone know how I fix this? Here is my products.php page: <?php /** * Google Sitemap Generator * * Script to generate a Google sitemap for osCommerce based stores * * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.2 * @link http://www.oscommerce-freelancers.com/ osCommerce-Freelancers * @copyright Copyright 2006, Bobby Easland * @author Bobby Easland * @filesource */ /* * Include the application_top.php script */ include_once('includes/application_top.php'); /* * Send the XML content header */ header('Content-Type: text/xml'); /* * Echo the XML out tag */ echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; ?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <?php /* * Define the uniform node function */ function GenerateNode($data){ $content = ''; $content .= "\t" . '<url>' . "\n"; $content .= "\t\t" . '<loc>'.trim($data['loc']).'</loc>' . "\n"; $content .= "\t\t" . '<lastmod>'.trim($data['lastmod']).'</lastmod>' . "\n"; $content .= "\t\t" . '<changefreq>'.trim($data['changefreq']).'</changefreq>' . "\n"; $content .= "\t\t" . '<priority>'.trim($data['priority']).'</priority>' . "\n"; $content .= "\t" . '</url>' . "\n"; return $content; } # end function /* * Define the SQL for the products query */ $sql = "SELECT products_id as pID, products_date_added as date_added, products_last_modified as last_mod, products_ordered FROM " . TABLE_PRODUCTS . " WHERE products_status = '1' ORDER BY products_last_modified DESC, products_date_added DESC, products_ordered DESC"; /* * Execute the query */ $query = tep_db_query($sql); /* * If there are returned rows... * Basic sanity check */ if ( tep_db_num_rows($query) > 0 ){ /* * Initialize the variable containers */ $container = array(); $number = 0; $top = 0; /* * Loop the query result set */ while( $result = tep_db_fetch_array($query) ){ $top = max($top, $result['products_ordered']); $location = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $result['pID'], 'NONSSL', false); if ( tep_not_null($result['last_mod']) ){ $lastmod = $result['last_mod']; } else { $lastmod = $result['date_added']; } $changefreq = 'weekly'; $ratio = ($top > 0) ? ($result['products_ordered']/$top) : 0; $priority = $ratio < .1 ? .1 : number_format($ratio, 1, '.', ''); /* * Initialize the content container array */ $container = array('loc' => htmlspecialchars(utf8_encode($location)), 'lastmod' => date ("Y-m-d", strtotime($lastmod)), 'changefreq' => $changefreq, 'priority' => $priority ); /* * Echo the generated node */ echo generateNode($container); } # end while } # end if /* * Close the urlset */ echo '</urlset>'; /* * Include the application_bottom.php script */ include_once('includes/application_bottom.php'); ?> Quote
♥kymation Posted October 21, 2009 Posted October 21, 2009 I had problems with that as well. I didn't keep track of the changes, so here's the whole file: <?php /* $Id: sitemap_categories.php v1.4 2008-11-29 Kymation $ $Loc: catalog/ See http://www.sitemaps.org/protocol.php for the expected output Original author's information: * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @link http://www.oscommerce-freelancers.com/ osCommerce-Freelancers * @copyright Copyright 2006, Bobby Easland * @author Bobby Easland * @filesource */ //// // Set up and initialize data // Get all osCommerce functions and open the database connection include_once('includes/application_top.php'); // Set the frequency of change for your categories. // Valid values are: // always // hourly // daily // weekly // monthly // yearly // never define ('CHANGE_FREQUENCY', 'weekly'); // Send the XML content header header ('Content-Type: text/xml'); // Output the XML and opening URLSET tags echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; echo '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' . "\n" . 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 ' . "\n" . 'http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" ' . "\n" . 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n"; // Initialize the data array $xml_data = array(); //// // Get the products data and format it // SQL for the products data $sql = "SELECT products_id as pID, products_date_added as date_added, products_last_modified as last_mod, products_ordered FROM " . TABLE_PRODUCTS . " WHERE products_status = '1' ORDER BY products_last_modified DESC, products_date_added DESC, products_ordered DESC"; $query = tep_db_query ($sql); // Check that the query returned some data if (tep_db_num_rows ($query) > 0) { // Set initial parameters $top = 0; // Loop through the query result and populate the container array while ($result = tep_db_fetch_array ($query) ) { $location = tep_href_link (FILENAME_PRODUCT_INFO, 'products_id=' . $result['pID'], 'NONSSL', false); $lastmod = max ($result['last_mod'], $result['date_added'] ); // Calculate priority based on number of products ordered $top = max ($top, $result['products_ordered']); $ratio = ($top > 0) ? ($result['products_ordered'] / $top) : 0; $priority = number_format ($ratio, 4, '.', ''); // Set up the products data $xml_data = array ('loc' => htmlspecialchars (utf8_encode ($location) ), 'lastmod' => date ("Y-m-d", strtotime ($lastmod) ), 'changefreq' => CHANGE_FREQUENCY, 'priority' => $priority ); // Output an XML node for each product echo tep_generate_sitemap_node ($xml_data); } // while ($result } //if (tep_db_num_rows //// // Finish up and quit // Output the closing urlset echo '</urlset>'; // Cleanup include_once ('includes/application_bottom.php'); ?> Regards Jim Quote See my profile for a list of my addons and ways to get support.
bgtes Posted December 21, 2012 Posted December 21, 2012 (edited) Hi Jim, I have the same problem with date but when upload your map google giving me eror - invalid url.Can you help me? Thank you! Edited December 21, 2012 by bgtes Quote
Jack_mcs Posted December 21, 2012 Posted December 21, 2012 You may want to try the Google XML Sitemap SEO add instead. It is based on his code but ehanced in a number of ways. Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons
bgtes Posted December 21, 2012 Posted December 21, 2012 Thanks for the quick reply. Do you think I'll lose my indexed pages and google will start index them again if replaced with v 1.5 because my site has thousands of pages Quote
Jack_mcs Posted December 21, 2012 Posted December 21, 2012 No, it shouldn't make a difference because the urls should be the same. If they are not the same, the updating will cause them to be correct so, if anything, it will improve the ratings. Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.