Zen Cart Logo

SitemapXML v.2

Views: 613,213

Results 2,181 to 2,200 of 2,226
6 Mar 2025, 12:46 PM
#2181
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

SitemapXML v.2

yesaul:

Hello, another one short notice...

As in "box_news" table all datetime columns (not only 'news_modified_date') can be NULL, it would be wise to use IFNULL function also for checking 'news_published_date' column in sql-queries in includes\modules\pages\sitemapxml\sitemapxml_boxnews.php file:

echo '<h3>' . TEXT_HEAD_BOXNEWS . '</h3>';
$last_date = $db->Execute(
"SELECT MAX(GREATEST(n.news_added_date, IFNULL(n.news_modified_date, '0001-01-01 00:00:00'), IFNULL(n.news_published_date, '0001-01-01 00:00:00'))) AS last_date
FROM " . TABLE_BOX_NEWS . " n
WHERE n.news_status = 1
AND NOW() BETWEEN n.news_start_date AND n.news_end_date"
);
$table_status = $db->Execute("SHOW TABLE STATUS LIKE '" . TABLE_BOX_NEWS . "'");
$last_date = max($table_status->fields['Update_time'], $last_date->fields['last_date']);
if ($sitemapXML->SitemapOpen('boxnews', $last_date)) {
$news = $db->Execute(
"SELECT n.box_news_id, GREATEST(n.news_added_date, IFNULL(n.news_modified_date, '0001-01-01 00:00:00'), IFNULL(n.news_published_date, '0001-01-01 00:00:00')) AS last_date, nc.languages_id AS language_id
FROM " . TABLE_BOX_NEWS . " n
INNER JOIN " . TABLE_BOX_NEWS_CONTENT . " nc
ON n.box_news_id = nc.box_news_id
AND nc.languages_id IN (" . $sitemapXML->getLanguagesIDs() . ")
AND nc.news_title != ''
WHERE n.news_status = 1
AND NOW() BETWEEN n.news_start_date AND n.news_end_date" .
(SITEMAPXML_BOXNEWS_ORDERBY !== '' ? ' ORDER BY ' . SITEMAPXML_BOXNEWS_ORDERBY : '')
);
$sitemapXML->SitemapSetMaxItems($news->RecordCount());
foreach ($news as $next_item) {
$sitemapXML->writeItem(FILENAME_MORE_NEWS, 'news_id=' . $next_item['box_news_id'], $next_item['language_id'], $next_item['last_date'], SITEMAPXML_BOXNEWS_CHANGEFREQ);
}

$sitemapXML->SitemapClose();
unset($news);

}

> 
> This will help to avoid PHP-warnings by passing ***NULL*** as parameter
> 
> As "*box_news*" table is an 'external' table for this addon (created in another module), no additional verification can be excessive, I think
Yet another GitHub issue opened: <https://github.com/lat9/sitemapxml/issues/53>
6 Mar 2025, 1:22 PM
#2182
yesaul avatar

yesaul

New Zenner

Join Date:
Apr 2011
Location:
Espoo, Finland
Posts:
71
Plugin Contributions:
0

Re: SitemapXML v.2

Yet another GitHub issue opened
I have even more...

As $from and $where variables can be not empty in 'includes/modules/pages/sitemapxml/sitemapxml_ezpages.php' file after fixing the bug with using of quotes for TABLE_EZPAGES_TEXT constant (see earlier correspondence in this tread), "p." prefix must be added to all columns belonging to TABLE_EZPAGES table in all sql-queries, for ex:

    $page_query_sql =
        "SELECT p.toc_chapter
           FROM " . TABLE_EZPAGES . " [B]p[/B] " . $from . "
          WHERE p.alt_url_external = ''
            AND (
                (p.status_header = 1 AND p.header_sort_order > 0)
                 OR (p.status_sidebox = 1 AND p.sidebox_sort_order > 0)
                 OR (p.status_footer = 1 AND p.footer_sort_order > 0)
                )
           AND p.status_toc != 0" .
           $where . "
         GROUP BY p.toc_chapter";
6 Mar 2025, 6:59 PM
#2183
wsworx avatar

wsworx

Zen Follower

Join Date:
Jun 2012
Location:
California
Posts:
260
Plugin Contributions:
0

Re: SitemapXML v.2

lat9:

I agree; it's something to do with using the php form of invocation for the cron-job. Try the following instead:

GET 'https://your_domain/index.php?main_page=sitemapxml&rebuild=yes'

That seems to have taken care of the issue lat9, thank you.
No more debug logs and no errors in my hosting site error logs so it must have worked.

7 Mar 2025, 10:49 AM
#2184
shop_suey avatar

shop_suey

Zen Follower

Join Date:
Feb 2014
Location:
Germany
Posts:
375
Plugin Contributions:
0

Re: SitemapXML v.2

I'm using Firefox at the moment and a new sitemap can't be created.
The popup is being openend and the Url within looks ok but the content of the popup is just blank page and the sitemap is not being re-generated.

Unfortunately I can't use chromium at the moment to have the job done.

Is this a known issue?

7 Mar 2025, 11:10 AM
#2186
shop_suey avatar

shop_suey

Zen Follower

Join Date:
Feb 2014
Location:
Germany
Posts:
375
Plugin Contributions:
0

Re: SitemapXML v.2

You're right. There's one:

PHP Fatal error: Uncaught Error: Undefined constant "NAVBAR_TITLE" in /includes/modules/pages/sitemapxml/header_php.php:28
Stack trace:
#0 /index.php(36): require()
#1 {main}
thrown in /includes/modules/pages/sitemapxml/header_php.php on line 28
7 Mar 2025, 12:12 PM
#2187
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: SitemapXML v.2

Shop Suey:

You're right. There's one:

PHP Fatal error: Uncaught Error: Undefined constant "NAVBAR_TITLE" in /includes/modules/pages/sitemapxml/header_php.php:28
Stack trace:
#0 /index.php(36): require()
#1 {main}
thrown in /includes/modules/pages/sitemapxml/header_php.php on line 28

What version of Zen Cart is in use?  The SitemapXML distribution provides /includes/languages/english/lang.sitemap.xml, which includes that language-constant.
7 Mar 2025, 12:30 PM
#2188
shop_suey avatar

shop_suey

Zen Follower

Join Date:
Feb 2014
Location:
Germany
Posts:
375
Plugin Contributions:
0

Re: SitemapXML v.2

I now understand this is not a known issue.
I'm using the PHP 8.3 compatible European branch for German language version (1.5.7h)
I wrote a bug report at github

7 Mar 2025, 1:27 PM
#2189
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: SitemapXML v.2

yesaul:

I have even more...

As $from and $where variables can be not empty in 'includes/modules/pages/sitemapxml/sitemapxml_ezpages.php' file after fixing the bug with using of quotes for TABLE_EZPAGES_TEXT constant (see earlier correspondence in this tread), "p." prefix must be added to all columns belonging to TABLE_EZPAGES table in all sql-queries, for ex:

$page_query_sql =
    "SELECT p.toc_chapter
       FROM " . TABLE_EZPAGES . " [B]p[/B] " . $from . "
      WHERE p.alt_url_external = ''
        AND (
            (p.status_header = 1 AND p.header_sort_order > 0)
             OR (p.status_sidebox = 1 AND p.sidebox_sort_order > 0)
             OR (p.status_footer = 1 AND p.footer_sort_order > 0)
            )
       AND p.status_toc != 0" .
       $where . "
     GROUP BY p.toc_chapter";
GitHub issue created: <https://github.com/lat9/sitemapxml/issues/54>
7 Mar 2025, 3:19 PM
#2190
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: SitemapXML v.2

@yesaul, I've addresses all the issues you've identified in the SitemapXML github: https://github.com/lat9/sitemapxml

Would you mind doing a 3rd-party verification that I've addressed them all to your satisfaction?

8 Mar 2025, 11:20 AM
#2191
shop_suey avatar

shop_suey

Zen Follower

Join Date:
Feb 2014
Location:
Germany
Posts:
375
Plugin Contributions:
0

Re: SitemapXML v.2

Shop Suey:

I now understand this is not a known issue.
I'm using the PHP 8.3 compatible European branch for German language version (1.5.7h)
I wrote a bug report at github

I likely don't use the most recent version. So my fault likely. I'm going to test the most recent one.

9 Mar 2025, 4:01 PM
#2192
yesaul avatar

yesaul

New Zenner

Join Date:
Apr 2011
Location:
Espoo, Finland
Posts:
71
Plugin Contributions:
0

Re: SitemapXML v.2

@yesaul, I've addresses all the issues you've identified in the SitemapXML github: https://github.com/lat9/sitemapxml

Would you mind doing a 3rd-party verification that I've addressed them all to your satisfaction?

I am awfully sorry, I am probably not very familiar with Github mechanic, but I do still see something like

if ($sitemapXML->dbTableExist([B]'[/B]TABLE_HIDE_CATEGORIES[B]'[/B]) === true)

( \includes\modules\pages\sitemapxml\sitemapxml_categories.php flie, line 20)

in archive I have just downlaoded from GitHub

9 Mar 2025, 4:52 PM
#2193
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: SitemapXML v.2

yesaul:

I am awfully sorry, I am probably not very familiar with Github mechanic, but I do still see something like

if ($sitemapXML->dbTableExist([B]'[/B]TABLE_HIDE_CATEGORIES[B]'[/B]) === true)

> 
>  ( *\includes\modules\pages\sitemapxml\sitemapxml_categories.php* flie, line 20)
> 
> in archive I have just downlaoded from GitHub
Yep, that's to be expected.  You can download the current GitHub code using this link: <https://github.com/lat9/sitemapxml/archive/refs/heads/master.zip>
12 Mar 2025, 5:23 PM
#2194
yesaul avatar

yesaul

New Zenner

Join Date:
Apr 2011
Location:
Espoo, Finland
Posts:
71
Plugin Contributions:
0

Re: SitemapXML v.2

Yep, that's to be expected. You can download the current GitHub code

Hello, Thank you. I do not see any further issues.

Now you are using constant function in dbTableExist method, so constant names in quotes should be Ok
I should have noticed this earlier, sorry, my bad.

Thank you for your efforts supporting this addon

12 Mar 2025, 6:12 PM
#2195
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: SitemapXML v.2

yesaul:

Hello, Thank you. I do not see any further issues.

Now you are using constant function in dbTableExist method, so constant names in quotes should be Ok
I should have noticed this earlier, sorry, my bad.

Thank you for your efforts supporting this addon
And thanks back at you for the update; I'll get an updated version released real-soon-now!

12 Mar 2025, 6:26 PM
#2196
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: SitemapXML v.2

v4.0.4 of SitemapXML is now available for download: https://www.zen-cart.com/downloads.php?do=file&id=367

This release contains changes associated with these GitHub issues:

#50: Use !empty instead of direct comparison to an empty string, possible NULL values.
#51: Don't include manufacturers with no products in the manufacturers' sitemap output.
#52: Correct detection of plugin-supplied additional tables, e.g. TABLE_BOX_NEWS.
#53: TABLE_BOX_NEWS, 'news_published_date' field can be null.
#54: sitemapxml_ezpages.php: Ensure that all fields for TABLE_EZPAGES are prefixed with p.

13 Mar 2025, 8:18 AM
#2197
showren avatar

showren

New Zenner

Join Date:
Feb 2009
Location:
Taiwan
Posts:
11
Plugin Contributions:
0

Re: SitemapXML v.2

Hi lat9,

I'm using SitemapXML (formerly "Google Sitemap") - Version: v4.0.4 on Zen Cart 2.1.0, and I encountered a MySQL error when attempting to rebuild the sitemap. The issue specifically occurs with the Ezpages Sitemap generation.

Here’s the error from my logs:
[13-Mar-2025 08:03:17 UTC] Request URI: /index.php?main_page=sitemapxml&rebuild=yes, IP address: 220.133.4.108, Language id 4
#0 [internal function]: zen_debug_error_handler()
#1 /var/www/vhosts/hz.com.tw/httpdocs/includes/classes/db/mysql/query_factory.php(733): trigger_error()
#2 /var/www/vhosts/hz.com.tw/httpdocs/includes/classes/db/mysql/query_factory.php(678): queryFactory->show_error()
#3 /var/www/vhosts/hz.com.tw/httpdocs/includes/classes/db/mysql/query_factory.php(307): queryFactory->set_error()
#4 /var/www/vhosts/hz.com.tw/httpdocs/includes/modules/pages/sitemapxml/sitemapxml_ezpages.php(99): queryFactory->Execute()
#5 /var/www/vhosts/hz.com.tw/httpdocs/includes/templates/template_default/sitemapxml/tpl_main_page.php(21): require('...')
#6 /var/www/vhosts/hz.com.tw/httpdocs/index.php(94): require('...')
--> PHP Fatal error: MySQL error 1054: Unknown column 'p.sidebox_sort_orderASC' in 'order clause' :: SELECT *
FROM ezpages p
WHERE p.alt_url_external = ''
AND (
(p.status_header = 1 AND p.header_sort_order > 0)
OR (p.status_sidebox = 1 AND p.sidebox_sort_order > 0)
OR (p.status_footer = 1 AND p.footer_sort_order > 0) OR p.toc_chapter IN (0)
) ORDER BY p.sidebox_sort_orderASC, p.header_sort_orderASC, p.footer_sort_orderASC ==> (as called by) /var/www/vhosts/hz.com.tw/httpdocs/includes/modules/pages/sitemapxml/sitemapxml_ezpages.php on line 99 <== in /var/www/vhosts/hz.com.tw/httpdocs/includes/classes/db/mysql/query_factory.php on line 733.
Issue Summary:
The error seems to originate from ORDER BY in sitemapxml_ezpages.php, where column names are concatenated with "ASC" without a space.
The generated SQL query includes ORDER BY p.sidebox_sort_orderASC, p.header_sort_orderASC, p.footer_sort_orderASC, which is not valid SQL syntax.
This results in MySQL error 1054 (Unknown column 'p.sidebox_sort_orderASC').
Steps to Reproduce:
Install SitemapXML v4.0.4 on Zen Cart 2.1.0.
Run the sitemap rebuild via:
https://hz.com.tw/index.php?main_page=sitemapxml&rebuild=yes
The error occurs when generating the Ezpages Sitemap.
Possible Cause:
In sitemapxml_ezpages.php, the ORDER BY clause is constructed dynamically:
$order_by_elements = explode(',', SITEMAPXML_EZPAGES_ORDERBY);
If SITEMAPXML_EZPAGES_ORDERBY is missing spaces between column names and ASC, the query becomes invalid.
Temporary Fix:
I manually checked sitemapxml_ezpages.php and ensured that ORDER BY is formatted correctly:

ORDER BY p.sidebox_sort_order ASC, p.header_sort_order ASC, p.footer_sort_order ASC
This resolved the issue.

Request:
Could you confirm whether this is a bug in v4.0.4 and whether an official patch will be released?
If needed, I can provide additional debugging details.

Thanks for your help!

Best regards,
[showren]

13 Mar 2025, 11:29 AM
#2198
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: SitemapXML v.2

showren:

Hi lat9,

I'm using SitemapXML (formerly "Google Sitemap") - Version: v4.0.4 on Zen Cart 2.1.0, and I encountered a MySQL error when attempting to rebuild the sitemap. The issue specifically occurs with the Ezpages Sitemap generation.

Here’s the error from my logs:
[13-Mar-2025 08:03:17 UTC] Request URI: /index.php?main_page=sitemapxml&rebuild=yes, IP address: 220.133.4.108, Language id 4
#0 [internal function]: zen_debug_error_handler()
#1 /var/www/vhosts/hz.com.tw/httpdocs/includes/classes/db/mysql/query_factory.php(733): trigger_error()
#2 /var/www/vhosts/hz.com.tw/httpdocs/includes/classes/db/mysql/query_factory.php(678): queryFactory->show_error()
#3 /var/www/vhosts/hz.com.tw/httpdocs/includes/classes/db/mysql/query_factory.php(307): queryFactory->set_error()
#4 /var/www/vhosts/hz.com.tw/httpdocs/includes/modules/pages/sitemapxml/sitemapxml_ezpages.php(99): queryFactory->Execute()
#5 /var/www/vhosts/hz.com.tw/httpdocs/includes/templates/template_default/sitemapxml/tpl_main_page.php(21): require('...')
#6 /var/www/vhosts/hz.com.tw/httpdocs/index.php(94): require('...')
--> PHP Fatal error: MySQL error 1054: Unknown column 'p.sidebox_sort_orderASC' in 'order clause' :: SELECT *
FROM ezpages p
WHERE p.alt_url_external = ''
AND (
(p.status_header = 1 AND p.header_sort_order > 0)
OR (p.status_sidebox = 1 AND p.sidebox_sort_order > 0)
OR (p.status_footer = 1 AND p.footer_sort_order > 0) OR p.toc_chapter IN (0)
) ORDER BY p.sidebox_sort_orderASC, p.header_sort_orderASC, p.footer_sort_orderASC ==> (as called by) /var/www/vhosts/hz.com.tw/httpdocs/includes/modules/pages/sitemapxml/sitemapxml_ezpages.php on line 99 <== in /var/www/vhosts/hz.com.tw/httpdocs/includes/classes/db/mysql/query_factory.php on line 733.
Issue Summary:
The error seems to originate from ORDER BY in sitemapxml_ezpages.php, where column names are concatenated with "ASC" without a space.
The generated SQL query includes ORDER BY p.sidebox_sort_orderASC, p.header_sort_orderASC, p.footer_sort_orderASC, which is not valid SQL syntax.
This results in MySQL error 1054 (Unknown column 'p.sidebox_sort_orderASC').
Steps to Reproduce:
Install SitemapXML v4.0.4 on Zen Cart 2.1.0.
Run the sitemap rebuild via:
https://hz.com.tw/index.php?main_page=sitemapxml&rebuild=yes
The error occurs when generating the Ezpages Sitemap.
Possible Cause:
In sitemapxml_ezpages.php, the ORDER BY clause is constructed dynamically:
$order_by_elements = explode(',', SITEMAPXML_EZPAGES_ORDERBY);
If SITEMAPXML_EZPAGES_ORDERBY is missing spaces between column names and ASC, the query becomes invalid.
Temporary Fix:
I manually checked sitemapxml_ezpages.php and ensured that ORDER BY is formatted correctly:

ORDER BY p.sidebox_sort_order ASC, p.header_sort_order ASC, p.footer_sort_order ASC
This resolved the issue.

Request:
Could you confirm whether this is a bug in v4.0.4 and whether an official patch will be released?
If needed, I can provide additional debugging details.

Thanks for your help!

Best regards,
[showren]
I'll get that corrected on the next release. For now, you can just remove the redundant ' ASC' after each of the order-by clauses for the EZ-pages.

19 Mar 2025, 8:20 AM
#2199
showren avatar

showren

New Zenner

Join Date:
Feb 2009
Location:
Taiwan
Posts:
11
Plugin Contributions:
0

Re: SitemapXML v.2

Hi lat9,

Thank you for your prompt response! I have followed your suggestion and successfully resolved the issue in SitemapXML v4.0.4. Here’s what I did:

  1. Modifying init_sitemapxml.php
    I located the SITEMAPXML_EZPAGES_ORDERBY configuration in:
    /YOUR_Admin/includes/init_includes/init_sitemapxml.php

Originally, it was set as:

'SITEMAPXML_EZPAGES_ORDERBY' => [
'EZPages order by',
'p.sidebox_sort_order ASC, p.header_sort_order ASC, p.footer_sort_order ASC',
'',
60,
null,
null
],
To fix the issue, I removed the redundant ASC and updated it as:

'SITEMAPXML_EZPAGES_ORDERBY' => [
'EZPages order by',
'p.sidebox_sort_order, p.header_sort_order, p.footer_sort_order',
'',
60,
null,
null
],
2. Adjusting the ORDER BY Processing Logic
In init_sitemapxml.php, the following logic was present:

$order_by_elements = explode(',', str_replace(' ', '', SITEMAPXML_EZPAGES_ORDERBY));
foreach ($order_by_elements as $i => $element) {
if (strpos($element, 'p.') !== 0 && strpos($element, 'pt.') !== 0) {
$order_by_elements[$i] = 'p.' . $element;
}
}
$order_by = implode(', ', $order_by_elements);
This was removing all spaces, potentially causing ORDER BY p.sidebox_sort_orderASC (without a space).

To prevent this, I modified the logic:

$order_by_elements = explode(',', SITEMAPXML_EZPAGES_ORDERBY);
foreach ($order_by_elements as $i => $element) {
$element = trim($element); // Ensure spaces are preserved
if (strpos($element, 'p.') !== 0 && strpos($element, 'pt.') !== 0) {
$order_by_elements[$i] = 'p.' . $element;
}
}
$order_by = implode(', ', $order_by_elements);
Now, the ORDER BY clause correctly formats its output.

  1. Updating the Database Configuration
    Since Zen Cart saves configuration settings in the database, I executed the following SQL query to update the SITEMAPXML_EZPAGES_ORDERBY value:

UPDATE configuration
SET configuration_value = 'p.sidebox_sort_order, p.header_sort_order, p.footer_sort_order'
WHERE configuration_key = 'SITEMAPXML_EZPAGES_ORDERBY';
This ensures that existing settings do not retain the incorrect ASC formatting.

  1. Testing and Verifying
    Cleared the Zen Cart cache via Admin Panel (Tools → Template Cache → Reset).
    Rebuilt the Sitemap using:

https://******/index.php?main_page=sitemapxml&rebuild=yes
Checked error logs (php_error.log & myDEBUG
.log), confirming that the MySQL 1054 Unknown Column error was resolved.
Everything is now working smoothly!
Thanks again for your guidance—I appreciate your continued support in maintaining and improving Zen Cart.

Best regards,
Showren

5 Apr 2025, 12:27 PM
#2200
generikz avatar

generikz

New Zenner

Join Date:
Sep 2011
Location:
Tokyo
Posts:
26
Plugin Contributions:
0

Re: SitemapXML v.2

showren:

Checked error logs (php_error.log & myDEBUG*.log), confirming that the MySQL 1054 Unknown Column error was resolved.
Everything is now working smoothly!

PHP Fatal error: MySQL error 1054: Unknown column 'p.sidebox_sort_orderASC' in 'order clause'

I had the same issue and the fix above worked for me as well, thanks!

Julien