Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

X-Cart Product Images Sitemap Generator

 
Reply
   X-Cart forums > X-Cart 4 > Third Party Add-Ons for X-Cart 4
 
Thread Tools
  #1  
Old 03-29-2017, 06:54 PM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default X-Cart Product Images Sitemap Generator

  • Generates a separate product images sitemap to maximise Google Images SEO
  • Lists detailed images first, then product images, then thumbnails
  • Supports X-Cart Clean URLs by default
  • X-Cart v4.4.x - v4.7.x (for v4.4.x see note 8 )
  • Easy to install
Info
Quote:
Image sitemap information helps Google discover images that we might not otherwise find (such as images your site reaches with JavaScript code), and allows you to indicate images on your site that you want Google to crawl and index.

Download

Changelog


1st August 2018 - Updated, to handle special characters in image captions/titles better, geolocation and license info disabled by default, HTTPS urls used.

2nd April 2017 - Updated to use htmlspecialchars instead of htmlentities and added 'memory_limit' setting.

10th May 2017 - Updated, with note for v4.4.x stores.
__________________
xcartmods.co.uk
Reply With Quote

The following 5 users thank PhilJ for this useful post:
anandat (03-30-2017), elmirage001 (03-30-2017), ITVV (03-30-2017), mcinque (07-12-2018), wnc2 (03-31-2017)
  #2  
Old 03-30-2017, 12:20 AM
 
anandat anandat is offline
 

X-Adept
  
Join Date: Jan 2004
Posts: 914
 

Default Re: X-Cart Product Images Sitemap Generator

Hi Phil,
You are amazing..no words to describe my happiness...I just requested this stuff in forum yesterday & no time you created this module & that's also for FREE !!

It's generating image sitemap but even though my site url starting from https:// the sitemap data still generated http:// links !
But that's easy to replace in text editor in no time.

Also I am using CDN so can I replace image url with https://cdn.mysite.com/images/D/sample_image.jpg ?

Quick Tip to users:
------------------
If you have large number of products for example more than 5000 & if you are getting 500 -Internal Server Error generating site map then in your config.php increase memory limit to 256
For example ini_set('memory_limit','256M');
After you generate sitemap successfully you revert back it to your original memory value limit.
__________________
X-Cart: 4.7.7 LIVE
Skin:Ultra by xcartmods.co.uk
X-cart Modules: | ACR, Rich Google Search, Customer Testimonials | Cloud Search, | Websitecm: CDSEO (2.1.9)
---------------
Server: Linux
php: 5.3
mysql: 5.0.89
----------------
Reply With Quote

The following 3 users thank anandat for this useful post:
elmirage001 (03-30-2017), ITVV (03-30-2017), PhilJ (04-01-2017)
  #3  
Old 03-30-2017, 08:26 AM
 
ITVV ITVV is online now
 

X-Wizard
  
Join Date: Nov 2006
Location: UK
Posts: 1,164
 

Default Re: X-Cart Product Images Sitemap Generator

Hi @anandat

Quote:
Originally Posted by anandat
It's generating image sitemap but even though my site url starting from https:// the sitemap data still generated http:// links !
But that's easy to replace in text editor in no time.

Phil covers that very issue in the "install.txt" file! Have a read of "Notes 4)" for help on the http -v- https

@Phil Great little addon - Thank You Phil

Kind regards

ITVV
__________________
X-Cart Pro 4.7.12 Active and working great with reBOOT-reDUX
X-Cart Pro 4.6.6 Retired after 6 years of first class service
X-Cart Pro 4.1.7 Retired after 9 years of first class service

Apache: 2.4.25
PHP: 7.4.5
MariaDB: 10.1.44
Arch: x86_64
Reply With Quote

The following 2 users thank ITVV for this useful post:
elmirage001 (03-30-2017), PhilJ (04-01-2017)
  #4  
Old 03-30-2017, 03:25 PM
 
elmirage001 elmirage001 is offline
 

X-Wizard
  
Join Date: Apr 2007
Posts: 1,964
 

Default Re: X-Cart Product Images Sitemap Generator

Hi Phil,

You are amazing! I'll get when my workload slows down some. I'm in the middle of building our new house so my orders decide to jump 300%... Can't complain

Thank you so much!

Paul
__________________
X-Cart GoldPlus v4.7.12 | reBOOT (reDUX) Template v4.7.12.9 | Always The Best
Reply With Quote

The following user thanks elmirage001 for this useful post:
PhilJ (04-02-2017)
  #5  
Old 03-31-2017, 01:58 AM
 
wnc2 wnc2 is offline
 

Senior Member
  
Join Date: May 2003
Posts: 140
 

Default Re: X-Cart Product Images Sitemap Generator

hi phil,

thanks for your valuable addon.

i'm having some issues with products including strange chars in the name like & ™ ® and accented italian chars like àèìòù.

any solution?
__________________
www.wnc2.biz
4.7.6+ fashion walk + xbanners2 + xmenusR
cdseopro - xcms - OPC
enterprise hosting on handsonwebhosting
IMAC with Sierra 10.12
=======
5.3.3.1 on test (maybe ready in 2031)
Reply With Quote

The following user thanks wnc2 for this useful post:
PhilJ (04-01-2017)
  #6  
Old 04-01-2017, 07:52 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default Re: X-Cart Product Images Sitemap Generator

ok, I have updated the mod to use htmlspecialchars instead of htmlentities and tested with those characters.

I've also added a 'memory_limit' setting if needed (line 9).
__________________
xcartmods.co.uk
Reply With Quote

The following 3 users thank PhilJ for this useful post:
anandat (04-04-2017), elmirage001 (04-02-2017), ITVV (04-02-2017)
  #7  
Old 04-01-2017, 09:25 AM
 
wnc2 wnc2 is offline
 

Senior Member
  
Join Date: May 2003
Posts: 140
 

Default Re: X-Cart Product Images Sitemap Generator

Quote:
Originally Posted by PhilJ
ok, I have updated the mod to use htmlspecialchars instead of htmlentities and tested with those characters. Thanks.

problem solved THANKS
__________________
www.wnc2.biz
4.7.6+ fashion walk + xbanners2 + xmenusR
cdseopro - xcms - OPC
enterprise hosting on handsonwebhosting
IMAC with Sierra 10.12
=======
5.3.3.1 on test (maybe ready in 2031)
Reply With Quote
  #8  
Old 04-03-2017, 09:27 PM
 
mattstyle2 mattstyle2 is offline
 

Advanced Member
  
Join Date: Apr 2015
Posts: 54
 

Default Re: X-Cart Product Images Sitemap Generator

nice mod.. for old xcart versions and people using wcm_cdseo, change the query and first part of the foreach sections to this:

Code:
$images_D = db_query(" SELECT * FROM $sql_tbl[products] INNER JOIN $sql_tbl[images_D] ON $sql_tbl[products].productid = $sql_tbl[images_D].id WHERE forsale='Y' ORDER BY productid DESC LIMIT $products_limit "); while ($row = db_fetch_array($images_D)) { $results[] = $row; } foreach ($results as $result){ //$clean_url = $result['clean_url'] . $product_urls_extension; $pid=$result['productid']; $cdseo_url = func_query_first_cell("SELECT cdseoUrl FROM wcm_cdseo WHERE cdseoReplaceID='$pid' AND cdseoType='product'"); if ($cdseo_url!='') { $cdseo_url.=".html"; $clean_url=$cdseo_url; } else { continue; }

you have to do that for the images_p and images_t sections too.

-Matt
__________________
4.7.7.
php7.1, AWS RDS database
memcache, reboot theme AWS EC2 load balancer, 2 c5.large instances CDSEO Shop By Filters,
AC onepage checkout and checkout tools,
altercart cash rewards, bcse DPM for paypal
Reply With Quote

The following user thanks mattstyle2 for this useful post:
PhilJ (04-03-2017)
  #9  
Old 04-03-2017, 11:15 PM
 
mattstyle2 mattstyle2 is offline
 

Advanced Member
  
Join Date: Apr 2015
Posts: 54
 

Default Re: X-Cart Product Images Sitemap Generator

I rewrote this.. There was an issue with this making a new url LOC for each image file which didnt match the specs:
https://support.google.com/webmasters/answer/178636?hl=en


so google was saying there was 40k images and 40k urls in the sitemap.. not sure if I broke something or it happens to everyone..

This works perfect with xc4.1.12 with cdseo and should work with newer versions

this only does detailed imgs, splits files if there's more than 40k images..

uses https filenames.. note this code only works with CDSEO urls.. you can change the part that gets the url pretty easily though.


Code:
require "./auth.php"; //================== Settings ================== $sitemap_filename = "images_sitemap"; $products_limit = "1000000"; $sm=''; //$product_urls_extension = $config['SEO']['clean_urls_ext_p']; //$geolocation = $config['Company']['location_address'].", ".$config['Company']['location_city'].", ".$config['Company']['location_state_name'].", ".$config['Company']['location_zipcode'].", ".$config['Company']['location_country_name']; //$license_info_url = $https_location."/pages.php?pageid=3#images"; $geolocation = false; // Uncomment to not display geo_location info $license_info_url = false; // Uncomment to not display license info //================== / Settings ================ $images_sitemap = fopen($sitemap_filename.$sm.'.xml', "wb"); //----------------------- $build = '<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'."\n"; //----------------------- $count=0; $products=func_query("SELECT * FROM $sql_tbl[products] WHERE forsale='Y' ORDER BY productid DESC LIMIT $products_limit"); foreach ($products as $product) { $pid=$product['productid']; //get URL! $cdseo_url = func_query_first_cell("SELECT cdseoUrl FROM wcm_cdseo WHERE cdseoReplaceID='$pid' AND cdseoType='product'",true); if ($cdseo_url!='') { $cdseo_url.=".html"; $clean_url=$cdseo_url; } else { continue; //if no clean url, skip the product } $build .= "\t<url> <loc>$https_location/$clean_url</loc>\n"; $query="SELECT * FROM $sql_tbl[images_D] WHERE id='$pid'"; $images = func_query($query); foreach ($images as $result) { $build.="\t\t".'<image:image> <image:loc><![CDATA['.$https_location."/".str_replace(array("./"),"",$result['image_path']).']]></image:loc>'."\r\n"; if ($result['alt']) { $build .= "\t\t\t".'<image:caption>'.sanitize_for_xml($result['alt']).'</image:caption> <image:title>'.sanitize_for_xml($result['alt']).'</image:title>'."\r\n"; } if ($geolocation) { $build .= "\t".'<image:geo_location>'.htmlspecialchars($geolocation).'</image:geo_location>'."\r\n"; } if ($license_info_url) { $build .= "\t".'<image:license>'.$license_info_url.'</image:license>'."\r\n"; } $build .= "\t\t".'</image:image>'; $count ; } //end foreach image $build.="\n\t</url>\n"; if ($count>=40000) //split the file { $build .= '</urlset>'; if ($sm=='') $sm=2; else $sm ; fwrite($images_sitemap, $build); fclose($images_sitemap); $images_sitemap = fopen($sitemap_filename.$sm.'.xml', "wb"); $build = '<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'."\n"; $count=0; } } //end foreach product $build .= '</urlset>'; //----------------------- fwrite($images_sitemap, $build); fclose($images_sitemap); echo "DONE! images: $count\n"; exit; function sanitize_for_xml($v) { // Strip invalid UTF-8 byte sequences - this part may not be strictly necessary, could be separated to another function $v = mb_convert_encoding(mb_convert_encoding($v, 'UTF-16', 'UTF-8'), 'UTF-8', 'UTF-16'); // Remove various characters not allowed in XML $v = preg_replace('/[^\x{0009}\x{000A}\x{000D}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]/u', '?', $v); return htmlspecialchars($v); }
__________________
4.7.7.
php7.1, AWS RDS database
memcache, reboot theme AWS EC2 load balancer, 2 c5.large instances CDSEO Shop By Filters,
AC onepage checkout and checkout tools,
altercart cash rewards, bcse DPM for paypal
Reply With Quote

The following user thanks mattstyle2 for this useful post:
anandat (04-04-2017)
  #10  
Old 05-08-2017, 11:37 AM
 
mpcommercial mpcommercial is offline
 

Member
  
Join Date: Dec 2004
Posts: 28
 

Default Re: X-Cart Product Images Sitemap Generator

hello, Phil:

I installed the mod, but the sitemap it produces is blank: any ideas of what I might be missing?
__________________
Lorena Martinez
X-Cart v4.3.2
www.lapislazuliworld.com
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Third Party Add-Ons for X-Cart 4


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:27 AM.

   

 
X-Cart forums © 2001-2020