Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

XML Sitemap Generator


ruden

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

 

Link to comment
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

Link to comment
Share on other sites

  • 2 weeks later...

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 ?

Link to comment
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)

Link to comment
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.

 

Link to comment
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

Link to comment
Share on other sites

  • 3 months later...
  • 3 weeks later...
  • 3 months later...

 

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?

 

Link to comment
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]

Link to comment
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...

 

Link to comment
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...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...