Post by aledmann » Wed Nov 16, 2011 9:16 pm

Hi everyone, I'm having a problem with my OC sitemap at the moment. When I upload it to Google I get an error message saying the file format is unsupported? I've enabled the extension and copied the URL given but when I check the URL in a browser, I get the following error message:

Code: Select all

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'p.product_id ASC ASC' at line 1
Error No: 1064
SELECT p.product_id, (SELECT AVG(rating) AS total FROM review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM product p LEFT JOIN product_description pd ON (p.product_id = pd.product_id) LEFT JOIN product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '1' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '0' GROUP BY p.product_id ORDER BY p.sort_order ASC p.product_id ASC ASC
Can anyone shed any light on why this is happening?

Thank you! :D
Last edited by aledmann on Thu Nov 17, 2011 10:17 pm, edited 1 time in total.

User avatar
New member

Posts

Joined
Thu Sep 08, 2011 9:56 pm

Post by aledmann » Thu Nov 17, 2011 4:26 am

OK...am I right in thinking that there is a problem with this code? This is what the Google SQL error message is leading me to believe anyway! Or am I completely wrong? :laugh:

Code: Select all

		if (!$product_data) {
			$sql = "SELECT p.product_id, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'";

User avatar
New member

Posts

Joined
Thu Sep 08, 2011 9:56 pm

Post by uksitebuilder » Thu Nov 17, 2011 5:28 pm

The problem is going to be in the sort by code

I see in your first post at the end p.product_id ASC ASC

The double ASC will be causing the error

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by aledmann » Thu Nov 17, 2011 6:19 pm

Thanks uksitebuilder. I thought that might be the problem...I just can't find the doubled up ASC ASC anywhere!

User avatar
New member

Posts

Joined
Thu Sep 08, 2011 9:56 pm

Post by uksitebuilder » Thu Nov 17, 2011 9:44 pm

It is either in catalog/model/catalog/product.php in the getProducts function

or catalog/controller/feed/google_sitemap.php

There are 2 variables $sort and $order

$order gets appended to $sort - Therefore whatever is defined in $sort should not have an 'ASC' at the end of the string, because most likely $order is set to ASC

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by aledmann » Thu Nov 17, 2011 10:15 pm

Cheers UKSB! Fixed it now!! I removed ASC from the rule below in catalog/model/catalog/product.php and it's all good in the hood now! :D


} else {
$sql .= " ORDER BY p.sort_order ASC, p.product_id ASC";
}

User avatar
New member

Posts

Joined
Thu Sep 08, 2011 9:56 pm
Who is online

Users browsing this forum: No registered users and 1 guest