nletresor Posted August 22, 2016 Share Posted August 22, 2016 (edited) 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. /** DbCore->displayError - [line 325 - classes/db/Db.php] - [1 Arguments] DbCore->query - [line 547 - classes/db/Db.php] - [1 Arguments] DbCore->getRow - [line 572 - classes/db/Db.php] - [2 Arguments] DbCore->getValue - [line 662 - classes/order/Order.php] - [1 Arguments] OrderCore->setProductImageInformations - [line 573 - classes/order/Order.php] - [1 Arguments] OrderCore->getProducts - [line 269 - modules/mailalerts/mailalerts.php] MailAlerts->hookActionValidateOrder - [line 507 - classes/Hook.php] - [1 Arguments] HookCore::exec - [line 650 - classes/PaymentModule.php] - [2 Arguments] PaymentModuleCore->validateOrder - [line 64 - modules/bankwire/controllers/front/validation.php] - [9 Arguments] BankwireValidationModuleFrontController->postProcess - [line 171 - classes/controller/Controller.php] ControllerCore->run - [line 373 - classes/Dispatcher.php] DispatcherCore->dispatch - [line 28 - index.php] 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 Edited August 22, 2016 by nletresor (see edit history) Link to comment Share on other sites More sharing options...
Gabriel Perez Posted August 22, 2016 Share Posted August 22, 2016 (edited) Hi. You just have a sql error. Try this instead: WHERE i.id_product = (i gues you have modified the setProductImageInformations funciton on the order class. If so, please do an override of the class.) Edited August 22, 2016 by Gabriel Perez (see edit history) Link to comment Share on other sites More sharing options...
nletresor Posted August 22, 2016 Author Share Posted August 22, 2016 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 More sharing options...
Gabriel Perez Posted August 23, 2016 Share Posted August 23, 2016 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. 1 Link to comment Share on other sites More sharing options...
musicmaster Posted August 23, 2016 Share Posted August 23, 2016 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 DbCore->displayError - [line 325 - classes/db/Db.php] - [1 Arguments] DbCore->query - [line 547 - classes/db/Db.php] - [1 Arguments] DbCore->getRow - [line 572 - classes/db/Db.php] - [2 Arguments] DbCore->getValue - [line 662 - classes/order/Order.php] - [1 Arguments] OrderCore->setProductImageInformations - [line 573 - classes/order/Order.php] - [1 Arguments] OrderCore->getProducts - [line 269 - modules/mailalerts/mailalerts.php] MailAlerts->hookActionValidateOrder - [line 507 - classes/Hook.php] - [1 Arguments] HookCore::exec - [line 650 - classes/PaymentModule.php] - [2 Arguments] PaymentModuleCore->validateOrder - [line 64 - modules/bankwire/controllers/front/validation.php] - [9 Arguments] BankwireValidationModuleFrontController->postProcess - [line 171 - classes/controller/Controller.php] ControllerCore->run - [line 373 - classes/Dispatcher.php] DispatcherCore->dispatch - [line 28 - index.php] 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 More sharing options...
nletresor Posted August 23, 2016 Author Share Posted August 23, 2016 Ok, it was just this line of code, thanks to you, the problem is gone Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now