无法从magento中的用户引用中删除项目

时间:2016-12-05 08:19:00

标签: magento magento-1.9

我无法从用户引用中删除项目。

var_dump($product->getQty(), $product_id, $item->getQty());
$quote->removeItem($item->getId())->save();

if ($quote->collectTotals()->save()) {
    var_dump(($quote->getId()), $item->getQty(), 'p');
    $_quote = Mage::getModel('sales/quote')->loadByCustomer($customer);

    $_product  = Mage::getModel('catalog/product')->load($product_id);
    var_dump(($_quote->getId()), $_product->getQty());
    $_quote->addProduct($_product, new Varien_Object($params));
    $quote->collectTotals()->save();

输出:

NULL string(4) "1465" int(100) string(4) "3325" int(100) string(1) "p" string(4) "3325" NULL {"status":"The requested quantity for \"Lava Lite 14.5\" Zebra Print Lava Lamp, Hot Pink Wax\" is not available."}

请帮帮我

1 个答案:

答案 0 :(得分:0)

尝试

$cartHelper = Mage::helper('checkout/cart');
$items = $cartHelper->getCart()->getItems();        
foreach ($items as $item) 
{
   $itemId = $item->getItemId();
   $cartHelper->getCart()->removeItem($itemId)->save();
}