I want to remove the bundle product from cart programmatically I am using

     $bundled_product_id = Mage::getModel("catalog/product")->loadByAttribute('sku',trim($skunew));
     $cartHelper = Mage::helper('checkout/cart');
        $items = $cartHelper->getCart()->getItems();
        foreach ($items as $item) {
            if ($item->getProduct()->getId() == $bundled_product_id) {
                $itemId = $item->getItemId();

In my cart bundle product sku="demobundle-demoprod1-demoprod4-demoprod5" give me some solution.how to remove or how to update this bundle.

  • And what is the problem with your code? Does it not remove the item? Does it do something else? Do you get an error Aug 1, 2016 at 14:38
  • @fschmengler actually I am updating bundle product programmatically from cart and adding it to cart but it is creating one more product with error message of some selections are missing.so want to remove the product from cart.
    – coder
    Aug 2, 2016 at 4:39
  • sounds like an xy-problem to me. Instead of removing a product that you did not want to add in the first place it would be better to fix your code to not add this product. Aug 2, 2016 at 16:08

1 Answer 1


Please try the following code.

$cart = Mage::getModel('checkout/cart')->getQuote();
$items = $cart->getAllItems();

foreach ($items as $_item){
   $_product = Mage::getModel('catalog/product')->load($_item->getProduct()->getId());

   if($_product->getTypeId()=== Mage_Catalog_Model_Product_Type::TYPE_BUNDLE){
       $options = $_item->getProduct()->getTypeInstance(true)->getOrderOptions($_item->getProduct());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.