Jump to content

Order impossible


nletresor

Recommended Posts

Hello, I have a problem with Prestashop. There is an error when you try to validate an order. After clicking on "je confirme ma commande" (cf screenshot), the following error occurs :

 

[PrestaShopDatabaseException]

Column 'id_product' in where clause is ambiguous
 

				SELECT image_shop.id_image				FROM ps_image i INNER JOIN ps_image_shop image_shop		ON (image_shop.id_image = i.id_image AND image_shop.id_shop = 1 AND image_shop.cover=1)				WHERE id_product = 6 LIMIT 1

at line 635 in file classes/db/Db.php

629. 			WebserviceRequest::getInstance()->setError(500, '[SQL Error] '.$this->getMsgError().'. From '.(isset($dbg[3]['class']) ? $dbg[3]['class'] : '').'->'.$dbg[3]['function'].'() Query was : '.$sql, 97);630. 		}631. 		else if (_PS_DEBUG_SQL_ && $errno && !defined('PS_INSTALLATION_IN_PROGRESS'))632. 		{633. 			if ($sql)634. 				throw new PrestaShopDatabaseException($this->getMsgError().'<br /><br /><pre>'.$sql.'</pre>');635. 			throw new PrestaShopDatabaseException($this->getMsgError());636. 		}637. 	}638. 639. 	/**

I have the same problem when I try to click on the order in the back office. MY version of prestashop is 1.6.0.9.

 

Can you help me ?

 

Thanks in advance,

 

Nicolas

http://www.savons-couronne.be

post-991078-0-23103100-1471864590_thumb.jpg

Edited by nletresor (see edit history)
Link to comment
Share on other sites

Thank you, but I don't understand what I have to change. Is it in the SQL database ?

 

I have never changed anything here and don't know how to find this specific element.

 

When you talk about the order class, is it the php file in prestashop -> classes -> order ? If so, also never touched that

Link to comment
Share on other sites

Sorry, I should have written it on another way, so you could understand it better.

 

In your original code, the where sentece uses the id_product field without the table prefix (in both image and image shop there are id_product), so there is your error.

WHERE id_product =

If you write an "i" before the id_product field, the error is gone (at this point i will not assume you have sql knowledge, to avoid further errors)

WHERE i.id_product =
On the other hand, yes, i refer to classes/order/order.php file.
This is really a small bug, that you may not suffer in a newer version of Prestashop, so doing an override perhaps its a bit exaggerated, but that is the way you do a change o the Prestashop code.
  • Like 1
Link to comment
Share on other sites

In version 1.6.1.0 Prestashop added a field id_product to the ps_image_shop table. It looks like you have code from before that change addressing a database from after the change. As Gabriel pointed out, you will need to add a specifier to that code.

 

As for what you should change. You listed the error queue like this

You should check all these files on the specified line numbers to see where the query came from.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...