javiersaord Posted January 4, 2016 Share Posted January 4, 2016 Hi, I have a flash module that calculates the measurements of the product, once calculated to give the button to add to cart see this error: [PrestaShopDatabaseException]Duplicate entry '739-6261-21011-0' for key 'PRIMARY' UPDATE `ps_cart_product` SET `id_address_delivery` = ( SELECT `id_address_delivery` FROM `ps_cart` WHERE `id_cart` = 739 AND `id_shop` = 1 ) WHERE `id_cart` = 739 at line 765 in file classes/db/Db.php 760. WebserviceRequest::getInstance()->setError(500, '[SQL Error] '.$this->getMsgError().'. From '.(isset($dbg[3]['class']) ? $dbg[3]['class'] : '').'->'.$dbg[3]['function'].'() Query was : '.$sql, 97); 761. } 762. elseif (_PS_DEBUG_SQL_ && $errno && !defined('PS_INSTALLATION_IN_PROGRESS')) 763. { 764. if ($sql) 765. throw new PrestaShopDatabaseException($this->getMsgError().'<br /><br /><pre>'.$sql.'</pre>'); 766. 767. throw new PrestaShopDatabaseException($this->getMsgError()); 768. } 769. } 770. DbCore->displayError - [line 418 - classes/db/Db.php] - [1 Arguments] 413. if ($this->connect()) 414. $this->result = $this->_query($sql); 415. } 416. 417. if (_PS_DEBUG_SQL_) 418. $this->displayError($sql); 419. 420. return $this->result; 421. } 422. 423. /** DbCore->query - [line 578 - classes/db/Db.php] - [1 Arguments] 573. public function execute($sql, $use_cache = true) 574. { 575. if ($sql instanceof DbQuery) 576. $sql = $sql->build(); 577. 578. $this->result = $this->query($sql); 579. if ($use_cache && $this->is_cache_enabled) 580. Cache::getInstance()->deleteQuery($sql); 581. 582. return (bool)$this->result; 583. } DbCore->execute - [line 3774 - classes/Cart.php] - [1 Arguments] 3769. '.(Configuration::get('PS_ALLOW_MULTISHIPPING') ? ' AND `id_shop` = '.(int)$this->id_shop : ''); 3770. 3771. $cache_id = 'Cart::setNoMultishipping'.(int)$this->id.'-'.(int)$this->id_shop.((isset($this->id_address_delivery) && $this->id_address_delivery) ? '-'.(int)$this->id_address_delivery : ''); 3772. if (!Cache::isStored($cache_id)) 3773. { 3774. if ($result = (bool)Db::getInstance()->execute($sql)) 3775. $emptyCache = true; 3776. Cache::store($cache_id, $result); 3777. } 3778. 3779. if (Customization::isFeatureActive()) CartCore->setNoMultishipping - [line 446 - override/controllers/front/OrderOpcController.php] 441. } 442. } 443. } 444. 445. // As the cart is no multishipping, set each delivery address lines with the main delivery address 446. $this->context->cart->setNoMultishipping(); 447. 448. $is_old_browser = false; 449. preg_match('/MSIE (.*?);/', $_SERVER['HTTP_USER_AGENT'], $matches); 450. if (count($matches) < 2) { 451. preg_match('/Trident\/\d{1,2}.\d{1,2}; rv:([0-9]*)/', $_SERVER['HTTP_USER_AGENT'], $matches); OrderOpcController->initContent - [line 180 - classes/controller/Controller.php] 175. 176. if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className))) 177. $this->initHeader(); 178. 179. if ($this->viewAccess()) 180. $this->initContent(); 181. else 182. $this->errors[] = Tools::displayError('Access denied.'); 183. 184. if (!$this->content_only && ($this->display_footer || (isset($this->className) && $this->className))) 185. $this->initFooter(); ControllerCore->run - [line 373 - classes/Dispatcher.php] 368. // Execute hook dispatcher 369. if (isset($params_hook_action_dispatcher)) 370. Hook::exec('actionDispatcher', $params_hook_action_dispatcher); 371. 372. // Running controller 373. $controller->run(); 374. } 375. catch (PrestaShopException $e) 376. { 377. $e->displayMessage(); 378. } DispatcherCore->dispatch - [line 28 - index.php] 23. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 24. * International Registered Trademark & Property of PrestaShop SA 25. */ 26. 27. require(dirname(__FILE__).'/config/config.inc.php'); 28. Dispatcher::getInstance()->dispatch(); with payment in five steps prestashop if it works but with the One Page Checkout module does not work and this error appears. I need help, please. Thanks. This is the image capture of the error Link to comment Share on other sites More sharing options...
Diurne Posted January 4, 2016 Share Posted January 4, 2016 The PRIMARY KEY used as an UNIQUE KEY cannot be the same as another key here your UPDATE change your id_address_delivery to 739-6261-21011-0 and seem to be already used. Link to comment Share on other sites More sharing options...
vekia Posted January 4, 2016 Share Posted January 4, 2016 key n ps_cart_product table contains 4 elements: - id_cart- id_product- id_address_delivery- id_product_attribute in your query you update the key element (id_address_delivery) from your sql update i see that id_address_delivery is equal to: 21011 and entry for this id cart and product already exist! 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