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)