简体   繁体   English

如何删除Magento中所有客户的所有购物车商品?

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

I want to delete all shopping cart items (products added to cart) of all customers in Magento. 我想删除Magento中所有客户的所有购物车项目(添加到购物车的产品)。

How can I do that? 我怎样才能做到这一点?

In detail :- 详细说明 :-

Suppose, I have total 10 registered customers in my shop. 假设我的商店中共有10个注册客户。 They might have items (products) added to cart. 他们可能已将商品添加到购物车。 I want to clear all items added to cart for all the 10 registered customers. 我想清除所有10个注册客户添加到购物车的所有项目。

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. 像这样循环遍历所有对象可能很慢,在SQL中这样做更快但不那么安全。

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. Inchoo日前发表了一篇文章,该文章将“购物车空”链接放在购物车页面上。

There's no “EMPTY CART” on Magento's cart page Magento的购物车页面上没有“空购物车”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM