[MSU Sitemaps] Links

Technical difficulties? Ask for help here.
capnhairdo
Posts: 5
Joined: Tue Mar 25, 2008 5:30 pm

[MSU Sitemaps] Links

Postby capnhairdo » Wed Mar 26, 2008 3:30 pm

Sample code generated by MSU Sitemaps:

Code: Select all

<url>
  <loc>http://www.babybestbuy.com/index.php?main_page=index&cPath=7_21</loc>
  <changefreq>weekly</changefreq>
  <priority>0.8</priority>
</url>
<url>
  <loc>http://www.babybestbuy.com/hot-deals-19/</loc>
  <changefreq>weekly</changefreq>
  <priority>0.8</priority>
</url>
<url>
  <loc>http://www.babybestbuy.com/hot-deals-19/index-2.html</loc>
  <changefreq>weekly</changefreq>
  <priority>0.8</priority>
</url>

Two questions:

In the first link, why is the old ZenCart style URL being used, rather than the MSEO version? In fact, why is this listing included at all? This is a category with no currently active products, so it therefore doesn't appear anywhere on our site (but we've retained it because we may reactive or add some new products at some point). If it doesn't appear on the site, I would think it shouldn't be included in the sitemap.

In the third link, why is "/index-2.html" appended to the address? There's a bunch like this, using index-2 or index-3.html.

Thanks.

inveo
Inveo Support
Posts: 1285
Joined: Sat Feb 02, 2008 12:07 pm
Contact:

Re: [MSU Sitemaps] Links

Postby inveo » Wed Mar 26, 2008 4:31 pm

capnhairdo wrote:In the first link, why is the old ZenCart style URL being used, rather than the MSEO version?


Old URIs are used when no cache data are available (they are created on first page visit).

capnhairdo wrote:In fact, why is this listing included at all? This is a category with no currently active products, so it therefore doesn't appear anywhere on our site (but we've retained it because we may reactive or add some new products at some point). If it doesn't appear on the site, I would think it shouldn't be included in the sitemap.


It is the best when Sitemaps contain all pages of your web even if they don't show any useful content yet.

capnhairdo wrote:In the third link, why is "/index-2.html" appended to the address? There's a bunch like this, using index-2 or index-3.html.


If pagenation does not correspond to the reality it is likely caused by some hard coding you have made to Zen Cart installation (it does affect MSU, only MSU Sitemaps).

capnhairdo
Posts: 5
Joined: Tue Mar 25, 2008 5:30 pm

Re: [MSU Sitemaps] Links

Postby capnhairdo » Wed Mar 26, 2008 9:50 pm

~J~ wrote:Old URIs are used when no cache data are available (they are created on first page visit).

Gotcha. This does in fact seem to be the case. Thanks for the tip. Seems to have only cropped up because disabled categories were being shown (for which no cache data had ever been created).

~J~ wrote:If pagenation does not correspond to the reality it is likely caused by some hard coding you have made to Zen Cart installation (it does affect MSU, only MSU Sitemaps).

I don't think so. After reviewing the code in sitemaps/categories.php, it seems the pagination count is being determined by retrieving the max number of results for search results pages (MAX_DISPLAY_SEARCH_RESULTS)...which is NOT (necessarily, though it could be coincidentally) the same as the max number of products on a category page (MAX_DISPLAY_PRODUCTS_LISTING). Thus the pagination breaks for category pages are being determined incorrectly by dividing by the wrong constant.

Additionally, retrieving the number of total products in a category is not the same as retrieving the number of ACTIVE products. This discrepancy could also affect pagination if disabled products exist. (Also, getting a product count would be more rigorous by doing a join back to the products table, rather than relying on the data in the TABLE_PRODUCTS_TO_CATEGORIES.)

~J~ wrote:It is the best when Sitemaps contain all pages of your web even if they don't show any useful content yet.

I disagree—it's illogical to tell a search engine to index pages that are intentionally disabled (and would be a waste of time for a visitor to follow these links from a search engine to a page that has products).

I was wrong in my previous post is assuming that the existence of (enabled) products in a category is what "enables" the category; ZenCart actually has an explicit field for this: categories_status. If set to 0, ZenCart never shows the category...but MSU Sitemaps does because it doesn't check this field, thus showing all categories, including explicitly disabled ones.

A final note: it seems like you could modify this loop:

Code: Select all

         do {
            $result2 = $db->Execute("SELECT categories_id, parent_id FROM ".TABLE_CATEGORIES." WHERE categories_id = '".$parentId."'");
            $cPath = $result2->fields['categories_id'].'_'.$cPath;
            $parentId = $result2->fields['parent_id'];
            if(empty($result2->fields['parent_id'])) break;
         } while(true);

to replace all the redundant queries to the database by instead just looping back through the original recordset and finding the parent ids from it, since you already have a full array of all category and parent ids there. (This is obviously a pretty minor performance gain since this page would only ever be hit periodically by search engines...but hey, every little bit helps.)

Applying all these changes to sitemaps/categories.php fixes the problems I mentioned:

Code: Select all

<?php

/**
  * MSU Sitemaps - Magic SEO URL URL for ZenCart
  * http://www.magic-seo-url.com/zencart/
  *
  * 2007, (c) Jiri Stavinoha
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
**/

if(!defined('SM_IN_SITEMAPS')) exit();

global $cache, $sm, $db;

$result = $db->Execute("SELECT configuration_value FROM ".TABLE_CONFIGURATION." WHERE configuration_key = 'MAX_DISPLAY_PRODUCTS_LISTING'");
$perPage = $result->fields['configuration_value'];
foreach($GLOBALS['smInstalledLang'] as $langId => $langCode) {
  $result = $db->Execute("SELECT c.categories_id, c.parent_id, COUNT(p.products_id) AS products_in_cat FROM ".TABLE_CATEGORIES." c LEFT JOIN ".TABLE_PRODUCTS_TO_CATEGORIES." pc ON pc.categories_id = c.categories_id LEFT JOIN ".TABLE_PRODUCTS." p ON pc.products_id = p.products_id AND p.products_status = 1 WHERE c.categories_status = 1 GROUP BY c.categories_id, c.parent_id ORDER BY c.categories_id DESC");
  $r1 = 0;
  while ($r1 < $result->RecordCount()) {
    $result->Move($r1++);
    $categoryId = $result->fields['categories_id'];
    $cPath = $categoryId;
    $parentId = $result->fields['parent_id'];
    $products_in_cat = $result->fields['products_in_cat'];
    if(!empty($parentId)) {
      do {
        $r2 = 0;
        while ($r2 < $result->RecordCount() ) {
          $result->Move($r2++);
          if ($result->fields['categories_id'] == $parentId) {
            $cPath = $result->fields['categories_id'].'_'.$cPath;
            $parentId = $result->fields['parent_id'];
            if(empty($parentId)) break 2;
            else break 1;
          }
        }
      } while(true);
    }
    $url = '';
    $fail = false;
    if(strpos($cPath, '_') === false) {
        $niceData = $cache->read('categories-parents', $categoryId, $langId);
        if(!$niceData) {
          $fail = true;
        } else {
          $url = $niceData[1].'-'.$categoryId.'/';
        }
    } else {
      $cPathAr = explode('_', $cPath);
      if(count($cPathAr) > 3) {
        $fail = true;
      } else {
        foreach($cPathAr as $cPathId) {
          $niceData = $cache->read('categories', $cPathId, $langId);
            if(!$niceData) {
              $fail = true;
              break;
            } else {
              $url .= $niceData[1].'-'.$cPathId.'/';
            }
       
        }
      }
    }
 
    if($GLOBALS['smMultilang']) {
      $url = $langCode.'/'.$url;
    }
   
    if($fail) {
      $url = UN_ZENCART_MAINFILE.'?main_page='.FILENAME_DEFAULT.'&amp;cPath='.$cPath.(($GLOBALS['smMultilang']) ? '&amp;language='.$langCode : '');
      $pagination = '&amp;page=__PAGE__';
    } else {
      $pagination = 'index-__PAGE__.html';
    }
   
    $sm->addUrlToSiteMap($url, 'weekly', '0.8');

    $pages = ceil($products_in_cat / $perPage);
   
    for ($i = 2; $i <= $pages; $i++) {
      $sm->addUrlToSiteMap($url.str_replace('__PAGE__', $i, $pagination), 'weekly', '0.8');
    }
  }
}
?>

BlessIsaacola
Follower
Posts: 98
Joined: Sun Feb 03, 2008 9:48 pm
Location: Kennesaw, GA
Contact:

Re: [MSU Sitemaps] Links

Postby BlessIsaacola » Fri Apr 11, 2008 11:44 pm

J- can you please comment on the code changes suggested if it's necessary or useful to apply this code change? Thanks!
http://www.clevershoppers.com - Where Clever People Shop!

BlessIsaacola
Follower
Posts: 98
Joined: Sun Feb 03, 2008 9:48 pm
Location: Kennesaw, GA
Contact:

Re: [MSU Sitemaps] Links

Postby BlessIsaacola » Sat Apr 12, 2008 5:20 pm

Is anyone else having problem with Google sitemap? We've being receiving errors lately:

URL timeout: HTTP request timeout
We encountered an error while trying to access your Sitemap. Please ensure your Sitemap follows our guidelines and can be accessed at the location you provided and then resubmit.

I am not exactly sure why all of a sudden, google is getting this error. The only sitemap having problem is url/sitemaps.php?showMap=Products
http://www.clevershoppers.com - Where Clever People Shop!

inveo
Inveo Support
Posts: 1285
Joined: Sat Feb 02, 2008 12:07 pm
Contact:

Re: [MSU Sitemaps] Links

Postby inveo » Tue Apr 15, 2008 9:06 am

New version of MSU Sitemaps will be available soon (also MSU API which allows to add easily support to other feed generators is under development).

BlessIsaacola
Follower
Posts: 98
Joined: Sun Feb 03, 2008 9:48 pm
Location: Kennesaw, GA
Contact:

Re: [MSU Sitemaps] Links

Postby BlessIsaacola » Wed Apr 30, 2008 11:20 am

Any updates on the new MSU Sitemaps? Thanks!
http://www.clevershoppers.com - Where Clever People Shop!

inveo
Inveo Support
Posts: 1285
Joined: Sat Feb 02, 2008 12:07 pm
Contact:

Re: [MSU Sitemaps] Links

Postby inveo » Wed Apr 30, 2008 12:14 pm

Update still coming.

inveo
Inveo Support
Posts: 1285
Joined: Sat Feb 02, 2008 12:07 pm
Contact:

Re: [MSU Sitemaps] Links

Postby inveo » Thu May 01, 2008 3:26 am

Updated MSU Sitemaps are now available for osCommerce, CRE Loaded and Zen Cart.

http://www.magic-seo-url.com/sitemaps/