Porpoise Posted April 25, 2013 Share Posted April 25, 2013 Am I correct in my assumption that once a cart has been converted to an order, it is no longer required by the system and can be safely deleted? Link to comment Share on other sites More sharing options...
vekia Posted April 25, 2013 Share Posted April 25, 2013 In my opinion, it is better so don't delete it. Why? In order variable - you've got another variable: cart object, so in this case - cart is necessary Link to comment Share on other sites More sharing options...
Porpoise Posted April 25, 2013 Author Share Posted April 25, 2013 On 4/25/2013 at 10:08 AM, vekia said: In my opinion, it is better so don't delete it. Why? In order variable - you've got another variable: cart object, so in this case - cart is necessary Hi Vekia, Thanks for your quick reply. I wonder why they've done it that way. I take it that the really dead carts, that can be safely deleted, are only the ones without an order number then. Link to comment Share on other sites More sharing options...
vekia Posted April 25, 2013 Share Posted April 25, 2013 im checking the order class code right now, maybe you've got right, im not sure at all. Maybe the cart object in order classes arent related to the cart database, we will see :-) Link to comment Share on other sites More sharing options...
Porpoise Posted May 10, 2013 Author Share Posted May 10, 2013 On 4/25/2013 at 11:27 AM, vekia said: im checking the order class code right now, maybe you've got right, im not sure at all. Maybe the cart object in order classes arent related to the cart database, we will see :-) Hi Vekia, Did you get an answer to this question? Regards, Steve Link to comment Share on other sites More sharing options...
vekia Posted May 10, 2013 Share Posted May 10, 2013 yes i checked it. After order cart information (products) is stored in ps_order_detail so cart isn't necessary Link to comment Share on other sites More sharing options...
Porpoise Posted May 11, 2013 Author Share Posted May 11, 2013 (edited) That's great news. Thanks for your research on that one. It will allow the page to load much quicker! EDIT: Having just tried deleting some carts, it appears that the system will not actually let you delete any carts which have become orders - in which case, I don't see why they should still show the dustbin (indicating that it is possible to delete them!?!) Edited May 11, 2013 by Porpoise (see edit history) Link to comment Share on other sites More sharing options...
PrestaMonster.com Posted May 11, 2013 Share Posted May 11, 2013 I agree, no need to store cart information in that case. But I think we should leave it there due to some module about data mining need to collect data from them. And in case we delete cart information about ps_cart, we have to change the code of classes, controllers, modules and back end heavily. So much of work. Link to comment Share on other sites More sharing options...
vekia Posted May 11, 2013 Share Posted May 11, 2013 Well, Im also think that we should leave this data, but it isn't necessary to collect them. You can try to delete cart from database. (be carefully!) @@PrestaMonster.com Quote And in case we delete cart information about ps_cart, we have to change the code of classes, controllers, modules and back end heavily. So much of work. Why? You mean, that if I delete some row from ps_cart it is necessary to change classes controllers? i dont think so Link to comment Share on other sites More sharing options...
PrestaMonster.com Posted May 11, 2013 Share Posted May 11, 2013 On 5/11/2013 at 9:51 AM, vekia said: Well, Im also think that we should leave this data, but it isn't necessary to collect them. You can try to delete cart from database. (be carefully!) @@PrestaMonster.com Why? You mean, that if I delete some row from ps_cart it is necessary to change classes controllers? i dont think so Hi vekia, The first one I found is in ParentOrderController.php, in init() function if (Tools::isSubmit('submitReorder') && $id_order = (int)Tools::getValue('id_order')) { $oldCart = new Cart(Order::getCartIdStatic($id_order, $this->context->customer->id)); $duplication = $oldCart->duplicate(); if (!$duplication || !Validate::isLoadedObject($duplication['cart'])) $this->errors[] = Tools::displayError('Sorry. We cannot renew your order.'); else if (!$duplication['success']) $this->errors[] = Tools::displayError('Some items are no longer available, and we are unable to renew your order.'); else { $this->context->cookie->id_cart = $duplication['cart']->id; $this->context->cookie->write(); if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) Tools::redirect('index.php?controller=order-opc'); Tools::redirect('index.php?controller=order'); } } That code is used for re-order function in order history page of customer. I've checked code under classes/order, there is no code to refer old cart information. Look like it's not so complex to remove these rows in ps_cart, but I am not sure about third-party module (especially payment module) invoke cart information. 1 Link to comment Share on other sites More sharing options...
vekia Posted May 11, 2013 Share Posted May 11, 2013 On 5/11/2013 at 10:17 AM, PrestaMonster.com said: Hi vekia, The first one I found is in ParentOrderController.php, in init() function ... That code is used for re-order function in order history page of customer. I've checked code under classes/order, there is no code to refer old cart information. Look like it's not so complex to remove these rows in ps_cart, but I am not sure about third-party module (especially payment module) invoke cart information. Now i totally agree with you :-) Link to comment Share on other sites More sharing options...
PrestaMonster.com Posted May 11, 2013 Share Posted May 11, 2013 On 5/11/2013 at 7:12 AM, Porpoise said: That's great news. Thanks for your research on that one. It will allow the page to load much quicker! EDIT: Having just tried deleting some carts, it appears that the system will not actually let you delete any carts which have become orders - in which case, I don't see why they should still show the dustbin (indicating that it is possible to delete them!?!) I recommend to leave them there. But in case you need to delete it, you can do it by MySQL command DELETE FROM ps_cart WHERE id_cart NOT IN (SELECT id_cart FROM ps_order); DELETE FROM ps_cart_product WHERE id_cart NOT IN (SELECT id_cart FROM ps_orders); Link to comment Share on other sites More sharing options...
Recommended Posts