【问题标题】:How to clear all cart items in magento cart (In all PCs from all over world)如何清除 magento 购物车中的所有购物车项目(在来自世界各地的所有 PC 中)
【发布时间】:2017-07-26 11:41:39
【问题描述】:

当我运行脚本时,然后从所有已添加购物车项目的 PC 中清除购物车项目。

【问题讨论】:

  • 我在 sql DELETE FROM sales_flat_quote WHERE is_active = 1; is_active = 0 的查询下运行了解决方案,表示这些报价已转换为订单,即客户已为这些报价下订单。 is_active = 1 表示尚未订购的报价,即客户购物车中存在的报价
  • 是的,这对我有用。

标签: magento-1.9


【解决方案1】:

试试下面的代码。

protected $quoteFactory;

public function __construct(
    ...
    \Magento\Quote\Model\QuoteFactory $quoteFactory,
    ....
) {
    ....
    $this->quoteFactory = $quoteFactory;
    ....
}

$quoteCollection = $this->quoteFactory->create()->getCollection()
          ->addFieldToFilter('is_active', 1);       

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

【讨论】:

    【解决方案2】:

    运行以下查询:

    quote 删除其中 is_active=1 AND reserved_order_id 为空

    现在从您的 Magento 根目录运行以下命令:

    截断 persistent_session

    【讨论】:

    • 在magento数据库中没有任何quote表只有报价相关的7个表。 1.sales_flat_quote 2.sales_flat_quote_item 3.sales_flat_quote_item_option 4.sales_flat_quote_address 5.sales_flat_quote_address_item 6.sales_flat_quote_payment 7.sales_flat_quote_shipping_rate
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-09
    • 2019-12-09
    • 2015-05-18
    • 1970-01-01
    • 1970-01-01
    • 2015-05-01
    • 1970-01-01
    相关资源
    最近更新 更多