3

I have a configurable product with associated simple products which I want to keep Inventory of. I set all the inventories to 10.

I've noticed that if I try to add 4 products to my cart, it won't let me. It says The requested quantity for [product] is not available.

I started digging for a solution. I found that in app/core/Mage/CatalogInventory/Model/Stock/item.php in the function checkQuoteItemQty, I'm getting funny values.

This function gets called from the observer located one folder up, Observer.php.

I started logging the parameters fed to checkQuoteItemQty and have found that it is squaring my requested quantities. If I order 3 products, it checks inventory for 9. When I order 4, it looks for 16 (which is above the limit of 10).

The observer runs for each Item in the quote. The quote has the simple product AND the configurable product in it. And the observer has a line $rowQty = $quoteItem->getParentItem()->getQty() * $qty; that is multiplying the two, and yielding the incorrect rowQty.

This seems too asinine to be the default behavior. Do I have something configured wrong? Why are the simple AND configurable products in the quote? Or why do they both have an qty value (of 4, in my case)

2
  • By any chance did you ever figure this out? I'm running into the same thing...
    – leek
    Oct 16, 2015 at 7:55
  • @leek, yeah...looks like I modified core. I did this a long time ago. And I don't think we noticed any downsides.... I posted an answer below. Good luck.
    – TimSum
    Oct 16, 2015 at 16:33

1 Answer 1

3

I modified core to fix this.

I know it's bad practice and maybe there's a downside. But I did this months ago and I don't think we've noticed any other problems...

Near line 478 in the Observer.php file, I commented out the original code and replaced it with my own that does not containt the * $qty. Here it is:

/**
 * This change made by __[myname]______ because the Qty was being squared
 */
 //$rowQty = $quoteItem->getParentItem()->getQty() * $qty;
 $rowQty = $quoteItem->getParentItem()->getQty();

Good luck.

1
  • 1
    Do you face the same problem on Magento 2 ? It seems to. Jun 27, 2017 at 9:08

Your Answer

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

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