Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you safely delete old entries in sales_flat_quote?

Tags:

magento

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.)?

like image 422
Peter O'Callaghan Avatar asked Feb 09 '12 16:02

Peter O'Callaghan


1 Answers

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/

like image 81
seanbreeden Avatar answered Oct 11 '22 14:10

seanbreeden