6

We have an install that is currently running Magento CE v1.5 (it has been upgraded over time, I think it started on approximately 1.1). The sales_flat_quote table currently has upward of 550,000 rows in it. A large percentage of these have a null customer_id and are many months old. I can't think of a reason to keep them around, since they are old and not associated with a customer there is assumably no way anybody can ever get access to that quote again.

It seems strange that Magento doesn't seem to have a built in functionality for removing what seems like junk information (they do have a cron for removing quotes, but as far as I can tell, it only removes quotes that are set to is_active false, which as far as I can tell only happens when a quote is converted to an order).

Essentially, what I'm asking is... a.) Is it safe to delete these entries? b.) What is the best way of doing it (pure sql, via model, some option in the control panel I've missed, etc.)?

2 Answers 2

6

We've had several sites that needed the order information cleared after going from dev to production. We did it by truncating the sales_flat_* and several other tables. We didn't have any problems with it. However, I recommend testing any direct database edits on a COPY of your database.

You can also delete records from sales_flat_quote even if you don't delete the corresponding order records or other tables in sales_flat_*. You should probably only delete records in the quote table that are more than 30 days old though, so that customers will have access to recent carts.

Here is a very helpful post from the Magento Commerce Forums. http://www.magentocommerce.com/boards/viewthread/1680/P405/

4
  • After running many tests we eventually ended up deleting everything from the sales_flat_quote table of our live site using MySQL (DELETE rather than TRUNCATE). Up to this point we have had no untoward effects. Commented Dec 24, 2012 at 13:03
  • If you don't truncate the other sales_flat_* tables then you can end up with some comments in new orders that carry over from the old, especially if you reset the auto_increment id. Commented Dec 24, 2012 at 20:16
  • As far as I can tell, all other quote related tables having foreign key contraints where required. Nothing else was reset, I merely removed rows from the tables maintaining any increments. Commented Dec 27, 2012 at 19:00
  • 1
    Here is the achived version of the dead link above: web.archive.org/web/20150228211104/http://…
    – HenryHayes
    Commented Nov 12, 2023 at 12:21
0

Please refer this site if you want to delete unwanted quote entry http://www.magentocommerce.com/boards/viewthread/53981/

http://www.magentocommerce.com/boards/v/viewthread/218244/#t297757

https://github.com/fbrnc/Aoe_QuoteCleaner

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.