Jump to content
ruden

XML Sitemap Generator

Recommended Posts

XML Sitemap Generator

For all version osCommerce create an XML sitemap for the products, categories and manufacturers, that can be submitted to Google, Bing.

Install
---------

Unzip the archive and upload the files on server.

In admin/includes/functions/general.php

Find
 

  function tep_redirect($url) {
    global $logger;


Add after
 

    // start add-on xml sitemap generator
    global $current_page;

    if (in_array($current_page, ['categories.php', 'manufacturers.php'])) {
      if (file_exists(DIR_FS_CATALOG . 'sitemap-index.xml')) {
        @unlink(DIR_FS_CATALOG . 'sitemap-index.xml');
      }
    }
    // end add-on xml sitemap generator


Using
--------

Sign in to Google Search Console or Bing Webmaster Tools and add sitemap URL http://example.com/sitemap.php

 

Share this post


Link to post
Share on other sites
1 hour ago, ruden said:

XML Sitemap Generator

For all version osCommerce create an XML sitemap for the products, categories and manufacturers, that can be submitted to Google, Bing.

Install
---------

Unzip the archive and upload the files on server.

In admin/includes/functions/general.php

Find
 


  function tep_redirect($url) {
    global $logger;


Add after
 


    // start add-on xml sitemap generator
    global $current_page;

    if (in_array($current_page, ['categories.php', 'manufacturers.php'])) {
      if (file_exists(DIR_FS_CATALOG . 'sitemap-index.xml')) {
        @unlink(DIR_FS_CATALOG . 'sitemap-index.xml');
      }
    }
    // end add-on xml sitemap generator


Using
--------

Sign in to Google Search Console or Bing Webmaster Tools and add sitemap URL http://example.com/sitemap.php

 

Could this not be done without core code changes? @burt

Share this post


Link to post
Share on other sites
15 minutes ago, LeeFoster said:

Could this not be done without core code changes? @burt

@LeeFoster If I remember right @burt has build XML files system for Google Webmasters, Bing and others ZERO core code changes (2015)


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites

I have a question: The Archive are the sitmap.php and a function file ? The changes in general.php ( which easily can be modded as a hook ) deletes automaticly the sitemap-index, if I request categories or manufacturers? So, if I do something automaticly, why not execute sitemap.php after saving a product and create an actual sitemap, instead of deleting the map, which google is looking for ?

Have I misunderstood something ?

Share this post


Link to post
Share on other sites
1 hour ago, Denzel said:

The changes in general.php ( which easily can be modded as a hook )

Yes, I will do so, for compatibility v2.3.x addon is added https://apps.oscommerce.com/p9Yyp&hook-system

1 hour ago, Denzel said:

why not execute sitemap.php after saving a product and create an actual sitemap,

Initially, it worked, but if a lot of products all terribly slowed down.

A link will be added to generate the map in dashboard (module security check)

Share this post


Link to post
Share on other sites

But why deleting the sitemap without telling someone while accessing categories or manufacturer ? Google will download the sitemap sometime you don't know, but if they find nothing... ?

Share this post


Link to post
Share on other sites

Why should categories be opened first, xml producer, and then sitemap-index.xml

Cannot open categories or manufacturer xml without running sitemap.php

Google will always run the file sitemap.php and read sitemap-index.xml

If you specify sitemap-index.xml in the Google search console, it will not work.

 

Share this post


Link to post
Share on other sites

If run sitemap.php, then a new xml files will be generated

Share this post


Link to post
Share on other sites

I've received this error while testing sitemap.php, any idea? Im using CE Phoenix 1.0.4

I've tested it with PHP 5.4, 7.0 and 7.1

 

Fatal error: Uncaught Error: Call to undefined function mysqli_fetch_all() in /xxxx/xxxxxx/public_html/catalog/includes/functions/sitemap.php:14 Stack trace: #0 /xxxx/xxxxxx/public_html/catalog/sitemap.php(142): tep_db_fetch_all(Object(mysqli_result)) #1 {main} thrown in /xxxx/xxxxxx/public_html/catalog/includes/functions/sitemap.php on line 14

Share this post


Link to post
Share on other sites

every so often on the control panel show this alert WARNING_SITEMAP_INDEX_XML_EXIST

What is this?

Share this post


Link to post
Share on other sites

 

On 1/14/2020 at 3:18 PM, ruden said:

If run sitemap.php, then a new xml files will be generated

First of all, thanks for your writing this nice add-on. 

I installed it and tested it and it apparently works fine on my multi-language website (4 active languages): I could verify that it actually generates all the different .xml files for the various languages that are active on my website. 

Checking the actual .xml files in a different language than English, however, gives me bad news: I could realize that the file listed as a Spanish product sitemap actually contains a product sitemap in French. French product sitemap is in French, however, the same happens with all the remaining sitemap files for all the other available languages: they are all in French, despite the default language is set to English.  In layman's terms, it seems to randomly take one among the available languages and that language stays the same for all product sitemaps regardless of the language.

Would you know how to fix the above issue?

 

Share this post


Link to post
Share on other sites
2 hours ago, ruden said:

@mendoh Give a link to your site.

Hello Ruden, thanks.

The multi-language website where I am trying to use your add-on is this: netgun.store/webshop

 

Share this post


Link to post
Share on other sites

In file sitemap.php this code

  if (SEARCH_ENGINE_FRIENDLY_URLS == 'true' || (defined('SEO_ENABLED') && SEO_ENABLED == 'true')) {
    $languages_array = tep_db_query("SELECT code FROM languages");
    while ($languages = tep_db_fetch_array($languages_array)) {
      $file_extension = ($languages['code'] == DEFAULT_LANGUAGE ? '' : '-' . $languages['code']);

      create_sitemap($file_extension . '.xml');
      create_sitemap_catalog($doc, $root, $file_extension . '.xml');
    }
  } else {
    create_sitemap();
    create_sitemap_catalog($doc, $root);
  }

replace with

  //if (SEARCH_ENGINE_FRIENDLY_URLS == 'true' || (defined('SEO_ENABLED') && SEO_ENABLED == 'true')) {
    $languages_array = tep_db_query("SELECT code FROM languages");
    while ($languages = tep_db_fetch_array($languages_array)) {
      $file_extension = ($languages['code'] == DEFAULT_LANGUAGE ? '' : '-' . $languages['code']);

      create_sitemap($file_extension . '.xml');
      create_sitemap_catalog($doc, $root, $file_extension . '.xml');
    }
  //} else {
  //  create_sitemap();
  //  create_sitemap_catalog($doc, $root);
  //}

OR

If you know what constant controls the inclusion of your SEO add-on, then just replace SEO_ENABLED with [YOUR_SEO_ADDON_ENABLED]

Share this post


Link to post
Share on other sites
5 hours ago, ruden said:

//if (SEARCH_ENGINE_FRIENDLY_URLS == 'true' || (defined('SEO_ENABLED') && SEO_ENABLED == 'true')) { $languages_array = tep_db_query("SELECT code FROM languages"); while ($languages = tep_db_fetch_array($languages_array)) { $file_extension = ($languages['code'] == DEFAULT_LANGUAGE ? '' : '-' . $languages['code']); create_sitemap($file_extension . '.xml'); create_sitemap_catalog($doc, $root, $file_extension . '.xml'); } //} else { // create_sitemap(); // create_sitemap_catalog($doc, $root); //}

😮 After replacing the file section as suggested, the add-on does not work any more and I am getting a 404 error when running the sitemap.php file, even if the file is actually present...

 

Share this post


Link to post
Share on other sites

I have noticed that a sitemap for the language in which the site is being browsed is generated and that language is extended to all the remaining sitemaps for all the other available languages, that is, although you actually get as many different sitemap files as the available languages, all of those files only show the one site language which was on at the time the sitemap.php file was run...

Share this post


Link to post
Share on other sites

Unfortunately this doesn't work with Ultimate SEO URLs, due to the language session.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×