Magento – Configurable Product turn Out of Stock when all child product are out of stock

magentomagento-1.6magento-1.7

Hey guys i got a little dilema. I am running Magento ver. 1.7.0.2

When you create a configurable product you must set the stock "in stock" and then you add the other additional products with different stock.

When the additional products stock goes to 0 the main configurable product still is "in stock".

I want that when all the additional products stock goes to 0 then the main configurable product stock to turn into "out of stock".

I am using this custom code for "out of stock" products to appear always at the bottom page. And unless the configurable product dont receive the option "out of stock" it cant go to bottom page.

$this->getSelect()->joinLeft(array('_inventory_table'=>$this->getTable('cataloginventory/stock_item')),"_inventory_table.product_id = e.entity_id",array('is_in_stock', 'manage_stock'));
$this->addExpressionAttributeToSelect('on_top','(CASE WHEN (((_inventory_table.use_config_manage_stock = 1) AND (_inventory_table.is_in_stock = 1)) OR  ((_inventory_table.use_config_manage_stock = 0) AND (1 - _inventory_table.manage_stock + _inventory_table.is_in_stock >= 1))) THEN 1 ELSE 0 END)',array());
$this->getSelect()->order('on_top DESC');

Best Answer

Have you made sure you have the correct Magento settings?

Inventory "Show Out Of Stock" = "No"
Configurable product Manage Stock = "No"
Simple product /Manage Stock = "Yes"
Related Topic