1

I was trying to update a quote item quantity programtically; but, it constantly throws an error "The requested quantity for". Can anybody please provide assistance to resolve this issue ? code follows:

$buyInfo = array(
    'qty' => 102,
    "super_attribute"=>array(175=>19)
);
$this->_quote->updateItem($quoteItemId, new Varien_Object($buyInfo))->save();

$this->_quote - Quote Object

$quoteItemId - Item Id Current quantity of the product in the quote: 100

Total stock of the product:150

Thanks!

0

Your Total qty for product is 150 and 100 is already added in quote so items available to add in quote is only 50 and you are trying to add 102

if your "super_attribute"=>array(175=>19) are not same as added in current quote it will add new item in quote.

| improve this answer | |
  • :I had added the same super attributes to the quote. $product = Mage::getModel('catalog/product')->load(3); $buyInfo = array( 'qty' => 100, "super_attribute"=>array(175=>19) ); $this->_quote->addProduct($product , new Varien_Object($buyInfo))->save(); – iqbalmp Nov 19 '15 at 5:31
  • I want just update the quantity from 100 to 102 in cart. Thanks! – iqbalmp Nov 19 '15 at 5:33
  • method updateItem() is adding old item + new item so it will be 100+102 = 202 – Minesh Patel Nov 19 '15 at 5:35
  • if ($resultItem->compare($item)) { // Product configuration is same as in other quote item $resultItem->setQty($resultItem->getQty() + $item->getQty()); $this->removeItem($item->getId()); break; } This is the case in updateItem() method – Minesh Patel Nov 19 '15 at 5:38
0

Yes, got it!

   $parentItem = $item->getParentItem() ?: $item; //Set quantity for parent item

$parentItem->setQty(102)->save();

It was that much simple :)

| improve this answer | |

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.