开发者

How to delete all shopping cart items of all customers in Magento?

I want to delete all shopping c开发者_JAVA百科art items (products added to cart) of all customers in Magento.

How can I do that?

In detail:-

Suppose, I have total 10 registered customers in my shop. They might have items (products) added to cart. I want to clear all items added to cart for all the 10 registered customers.


My first guess would be something like,

$items = Mage::getResourceModel('sales/quote_item_collection');

foreach ($items as $item) {
    $item->delete();
}

The cart items are stored as part of a 'quote'. Looping through them all like this might be slow, doing it in SQL is quicker but not as safe.

TRUNCATE `sales_flat_quote_item`;


I know, it's not related directly your question but might be help.

Inchoo has published an article a few days ago which is putting "Cart Empty" link on cart page.

There’s no “EMPTY CART” on Magento’s cart page

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜