Page 1 of 2

Google sitemap

Posted: Sat Aug 04, 2018 3:38 pm
by leeburgess
Oc 3.0.2.0

Error in Google sitemap
When running it says

This page contains the following errors:
error on line 1 at column 14: Extra content at the end of the document
Below is a rendering of the page up to the first error.

How do I resolve this please?

Re: Google sitemap

Posted: Sat Aug 04, 2018 8:25 pm
by straightlight
URL / route name unprovided. Forum rules.

Re: Google sitemap

Posted: Sat Aug 04, 2018 8:34 pm
by leeburgess
index.php?route=extension/feed/google_sitemap

Re: Google sitemap

Posted: Sun Aug 05, 2018 5:14 am
by straightlight

Re: Google sitemap

Posted: Sun Aug 05, 2018 5:14 am
by leeburgess
Just me with this error then?

Re: Google sitemap

Posted: Sun Aug 05, 2018 5:42 am
by straightlight
No … if a prior solution has been provided and pointed out on another topic, it is not necessarily because you are the only one encountering this issue.

Re: Google sitemap

Posted: Sun Aug 05, 2018 7:46 pm
by leeburgess
Done the above and still the same.

Re: Google sitemap

Posted: Sun Aug 05, 2018 8:49 pm
by straightlight
Error / Server access logs?

Re: Google sitemap

Posted: Mon Aug 06, 2018 1:10 am
by leeburgess
I did :) error says
This page contains the following errors:
error on line 1 at column 14: Extra content at the end of the document
Below is a rendering of the page up to the first error.
Notice
straightlight wrote:
Sun Aug 05, 2018 8:49 pm
Error / Server access logs?

Re: Google sitemap

Posted: Mon Aug 06, 2018 1:16 am
by leeburgess
In error logs I have
2018-08-05 17:12:48 - PHP Notice: getimagesize(): Read error! in /home/******/public_html/catalog/model/tool/image.php on line 14

Re: Google sitemap

Posted: Mon Aug 06, 2018 1:18 am
by straightlight
See this post: viewtopic.php?t=149445 . The issue you are encountering has nothing to do with google sitemap. However, the provided solution prior is also a patch for the XML output aside from your enquiry in this case.

Re: Google sitemap

Posted: Mon Aug 06, 2018 3:15 am
by leeburgess
Thank you :) how can I find the missing image as have over 5000 products.
straightlight wrote:
Mon Aug 06, 2018 1:18 am
See this post: viewtopic.php?t=149445 . The issue you are encountering has nothing to do with google sitemap. However, the provided solution prior is also a patch for the XML output aside from your enquiry in this case.

Re: Google sitemap

Posted: Mon Aug 06, 2018 3:25 am
by straightlight
You can always submit a new service request to get this done as a custom job due to high quantity of images.

Re: Google sitemap

Posted: Mon Aug 06, 2018 6:15 pm
by paulfeakins
leeburgess wrote:
Mon Aug 06, 2018 3:15 am
how can I find the missing image as have over 5000 products
If you'd like to get in touch I think we have a similar script somewhere, or post on the Commercial Support forum.

Re: Google sitemap

Posted: Mon Aug 06, 2018 9:19 pm
by straightlight
A little tweak I found when resizing new images from now on. Let's see if this baby tool will work nicely. In system/library/image.php file,

find:

Code: Select all

if ($this->mime == 'image/gif') {
				$this->image = imagecreatefromgif($file);
			} elseif ($this->mime == 'image/png') {
				$this->image = imagecreatefrompng($file);
			} elseif ($this->mime == 'image/jpeg') {
				$this->image = imagecreatefromjpeg($file);
			}
add below:

Code: Select all

$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
			
			if ($ext === 'jpg') {
				$ext = 'jpeg';
			}
			
			$gd_function = 'imagecreatefrom' . $ext;
			
			if (function_exists($gd_function) && @$gd_function($file) === FALSE) {
				$log = new Log('error.log');
				
				$log->write('Error: Bad image file: ' . $file . ' ' . $gd_function . '!');
			}
This will output the resized image errors in the admin - > systems - > maintenance - > error logs page. :)

Source: https://stackoverflow.com/questions/993 ... -or-broken

Re: Google sitemap

Posted: Mon Aug 06, 2018 9:22 pm
by straightlight
Minor code fixed on the above.

Re: Google sitemap

Posted: Mon Aug 06, 2018 11:07 pm
by straightlight
Another way to do this would be from the catalog/model/tool/image.php file,

find:

Code: Select all

$image_new = str_replace(' ', '%20', $image_new);  // fix bug when attach image on email (gmail.com). it is automatic changing space " " to +
add above:

Code: Select all

if ($this->getBadGDImage(DIR_IMAGE, $image_new)) {
			$this->log->write('Error: Bad image file: ' . htmlspecialchars_decode(DIR_IMAGE . $image_new));
		}
Then, at the bottom of the file,

replace:

Code: Select all

    }
}
with:

Code: Select all

protected function getBadGDImage($path, $image) {
		$results = array();
		
		$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));

		$allFiles = array_filter(iterator_to_array($iterator), function($file) {
			return $file->isFile();
		});

		foreach ($allFiles as $key => $files) {
			$key = str_replace('\\', '/', $key);
			
			$path_exploded = explode('/', trim($key));
			
			if (strstr($path_exploded[sizeof($path_exploded)- 1], '.')) {
				$mime_type = mime_content_type($key);
				
				$file = $path_exploded[sizeof($path_exploded) - 1];
				
				$path_defined = sizeof($path_exploded) - 1;
				
				$path_slice = array_slice($path_exploded, 0, $path_defined);
				
				$location = implode('/', $path_slice);
				
				if ($location == $path && $file == $image) {
					switch ($mime_type) {
						case "image/jpg":
						case "image/jpeg":
							$im = imagecreatefromjpeg($location . '/' . $file);
							break;
						case "image/png":
							$im = imagecreatefrompng($location . '/' . $file);
							break;
						case "image/gif":
							$im = imagecreatefromgif($location . '/' . $file);
							break;
					}
						
					if (!$im) {
						$results[] = array('location'				=> $location,
										   'file'					=> $file,
										  );
					}
				}
			}
		}
		
		return (array)$results;
	}
}
As for the admin/model/tool/image.php file,

find:

Code: Select all

if ($this->request->server['HTTPS']) {
follow the previous steps above from the catalog/model/tool/image.php steps. This should work as intended.

This should also output the bad images to the OC logs.

Same source (and re-worked).

Re: Google sitemap

Posted: Thu Aug 01, 2019 8:43 pm
by leeburgess
Sadly cannot get this to work

Re: Google sitemap

Posted: Fri Aug 02, 2019 6:58 pm
by straightlight
leeburgess wrote:
Thu Aug 01, 2019 8:43 pm
Sadly cannot get this to work
No details provided. Forum rules.

Re: Google sitemap

Posted: Fri Aug 02, 2019 9:46 pm
by leeburgess
straightlight wrote:
Fri Aug 02, 2019 6:58 pm
leeburgess wrote:
Thu Aug 01, 2019 8:43 pm
Sadly cannot get this to work
No details provided. Forum rules.
I have no corrupt images now but Google sitemap says

This page contains the following errors:
error on line 1 at column 14: Extra content at the end of the document
Below is a rendering of the page up to the first error.