2
votes

Magento version - 1.7.0.2

How works quantity for configurable products (CP)

For example, i have an attribute "size" with values from 20 to 32

So, i created 12 simple products with sizes 20, 21, 22, et**c (with **quantity = 1 for each product)

Then i created two different CP (cp1 and cp2) and selected in Associated Product tab those s*imple products with sizes*

If users buy cp1 with size = 20, then what system do?

i want to know detailed system logic in this case

Quantity of Simple product with size=20 would be 0 and cp1 would be "out of stock" or not?

Sorry for my english and thanks for any consultations about my issue!

2

2 Answers

8
votes

In Magento strictly saying, a Configurable product(CP) is not a product in itself, but a collection of simple products. When you are choosing among 10 colors of a CP is nothing but choosing 10 different simple products of the same color.

Suppose a store have only one RED Ball and two magic boxes CP1 and CP2.

Now you can take out the RED Ball from any of the boxes,as it is a magic box. But when you take out the ball from one of the boxes(CP1), the RED Ball can't be taken out from the other box(CP2) or from the CP1 as there is only One RED Ball.

Now you can have hundreds of Magic Boxes and you can take the RED Ball from any of the boxes(if the magician allows it- in this case store owner), but when the stock of RED Ball is out then nobody can take out the RED Ball from any of the boxes.

And to make the product out of stock when the Quantity becomes zero, you have to go to

System->Configuration->Inventory(under catalog tab)

As shown in the image below, set the field marked in red to zero. enter image description here

That's it. Hope I made your concept clear about Configurable Product. Enjoy...

3
votes

Yes, if you reduce the stock of an associated simple product, the stock status is updated in all of the parent configurable products that contain that simple product. The configurable products will only become out of stock if all of their own associated child products are out of stock.

The system logic is fairly complicated as Magento accommodates a number of built in product types, but is also designed to accommodate custom product types. Inventory can be managed (or not managed) in a variety of ways in these different product types.

When you complete an order in Magento, the quote object representing the shopping cart is converted to an order object. If you look in Mage/CatalogInventory/etc/config.xml you'll see that this module is observing events in the system that relate to inventory levels. A lot of these events are emitted by Mage_Sales_Model_Service_Quote::submitOrder() which is the method that is driving most of the conversion from a quote to an order. The CatalogInventory observer methods both reduce the inventory levels and issue requests to re-index the stock levels.

In Mage_CatalogInventory_Model_Stock_Status::updateStatus() on line 266 you can see the call that updates the stock status of all parents of a simple product when the simple product's stock status changes.