Fadlan Posted September 20, 2017 Share Posted September 20, 2017 Hello, I've got problem with Prestashop 1.5.6.2 that started acting weirdly. I can't get the cart to work, wandering arround code for half a day I found out in CartController on line 241 it is need guest_id for cart creation and that table ps_guests is full of empty records that I don't know why are like that. The only thing it saves from cookies is client loged in. Is it cookie generation and how to fix it? Link to comment Share on other sites More sharing options...
bellini13 Posted September 20, 2017 Share Posted September 20, 2017 take a backup of the table and then empty it. its really just collecting statistics, which you should disable anyway, and use google analytics for the statistics. Link to comment Share on other sites More sharing options...
Fadlan Posted September 21, 2017 Author Share Posted September 21, 2017 The problem is, thanks to that no client have id, the cart cannot be created. Link to comment Share on other sites More sharing options...
bellini13 Posted September 21, 2017 Share Posted September 21, 2017 This is the code from CartController, around line 241. What line exactly are you referring to that requires id_guest? Note: Line 241 is just an opening bracket, so I suspect you have made changes and line numbers no longer match the original // Add cart if no cart found if (!$this->context->cart->id) { if (Context::getContext()->cookie->id_guest) { $guest = new Guest(Context::getContext()->cookie->id_guest); $this->context->cart->mobile_theme = $guest->mobile_theme; } $this->context->cart->add(); if ($this->context->cart->id) $this->context->cookie->id_cart = (int)$this->context->cart->id; } Did you bother to try to empty the ps_guest table as I suggested? Also, what did you change in the recent days that would cause this issue. If it was working recently, and now it is no longer working, then that means something was changed... Link to comment Share on other sites More sharing options...
Fadlan Posted September 21, 2017 Author Share Posted September 21, 2017 if (Context::getContext()->cookie->id_guest) { $guest = new Guest(Context::getContext()->cookie->id_guest); $this->context->cart->mobile_theme = $guest->mobile_theme; } This is the lines that should create new guests that are later used in creating new cart. For the changes, I didn't change any php files. I've just added some products and categories, then my server had an error becouse there was not enough memory for db so I removed some logs and the site was working but buying products not. I think I'll just reinstall prestashop. Link to comment Share on other sites More sharing options...
bellini13 Posted September 22, 2017 Share Posted September 22, 2017 This line of code is a conditional statement, a guest is only creating if the id_guest exists in the cookie. So it is not required... if (Context::getContext()->cookie->id_guest) Perhaps re-installing Prestashop might be best, it's possible the store is in a corrupt state by running out of memory. Link to comment Share on other sites More sharing options...
Maurice Posted October 13, 2023 Share Posted October 13, 2023 I truncate Ps_Guest many times on different Shop and never got problems But i read in some forum that truncate ps_guest is not safe , be honest i do not think so but if someone know the reason appreciate a comment Regards Link to comment Share on other sites More sharing options...
musicmaster Posted October 13, 2023 Share Posted October 13, 2023 2 hours ago, Maurice said: I truncate Ps_Guest many times on different Shop and never got problems But i read in some forum that truncate ps_guest is not safe , be honest i do not think so but if someone know the reason appreciate a comment Regards It is safe. Many people do it. The only way it could bring problems is when someone built a module that relied in an irresponsible way on it. But I am not aware of such things. 1 Link to comment Share on other sites More sharing options...
Maurice Posted October 13, 2023 Share Posted October 13, 2023 1 ora fa, musicmaster dice: It is safe. Many people do it. The only way it could bring problems is when someone built a module that relied in an irresponsible way on it. But I am not aware of such things. Hi Thanks for your response Totally agree with you , maybe some module can create an issue with this mentioned table. 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