0

how to update downloadable product quantity in shopping cart in magento thuough php

$_product = Mage::getModel("catalog/product")->load($p_id);      
$quote = Mage::getSingleton('checkout/session')->getQuote();      
$item = $quote->getItemByProduct($_product);           
$quote->updateItem($item->getId(), array( 'qty' => $p_qty)); getCart()->save(); 
  • Is this a question ? – Prateek Dec 22 '15 at 14:43
  • yes, i m unable to increase or decrease the quantity of product in shopping cart item in magento 1.8 – Dhammapal Janbandhu Dec 23 '15 at 5:14
0

Try this:

$quoteId = 1251; 
$productItem['qty'] = 2;
$productId =  17;
$product = Mage::getModel("catalog/product")->load($productId);
$quote   = Mage::getModel("sales/quote")->load($quoteId);
$quoteItem = $quote->getItemByProduct($product); 

if ($productItem['qty'] > 0) {
    $quoteItem->setQty($productItem['qty']);
}
try {
    $quote->collectTotals()->save();
} catch (Exception $e) {
   echo $e->getMessage();
}
  • not work plz update codes. $quoteItem = $quote->getItemByProduct($product); after that line exception occcur in php – Dhammapal Janbandhu Dec 23 '15 at 6:28
  • what is issues are facing? – Abdul Dec 23 '15 at 8:09
  • according to customer login, i have to change product quantity in cart but not success . Is there having any update method for update quantity and my product has a downladable product which are E-book and Print-book type contains link – Dhammapal Janbandhu Dec 23 '15 at 8:14
  • $quoteItem->setQty($productItem['qty']); <-- error – Dhammapal Janbandhu Dec 23 '15 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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