Magento – Magento 1.9.0.1 don’t set out of stock automatically on simple products

configurable-productconfiguration

We are running a shop that has the inventory functions enabled. We have configurable products where the simple products can fall under a stock of 0 and are ordered from our supplier when a order hits us.

The current behavior is, that if a product falls to zero it is automatically set to "out of stock" and therefore not shown anymore in the frontend.

Our wanted behavior is, that the stock availability is NOT set by Magento or it is shown in the frontend that the simple product is out of stock.

We thought this should be possible by setting the Allow qty Below 0 setting to yes but unfortunately Magento still sets the availability from the simple product to "Out of stock".

Are some of our settings wrong or am I missing something else?

Best Answer

Warning, using setSkipSaleableCheck(true) appears to have an additional effect of showing disabled products in the dropdown.

The function which is affected by this setting is in Mage_Catalog_Block_Product_View_Type_Configurable:

public function getAllowProducts()
{
if (!$this->hasAllowProducts()) {
$products = array();
$skipSaleableCheck = Mage::helper('catalog/product')->getSkipSaleableCheck();
$allProducts = $this->getProduct()->getTypeInstance(true)
    ->getUsedProducts(null, $this->getProduct());
foreach ($allProducts as $product) {
    if ($product->isSaleable() || $skipSaleableCheck) {
        $products[] = $product;
    }
}
$this->setAllowProducts($products);
}
return $this->getData('allow_products');
}

if ($product->isSaleable() || $skipSaleableCheck) will therefore always be true

I am yet to dig through the isSaleable() function to determine exactly where this occurs (maybe someone can confirm) but my guess is that it includes a check against the products status which is missed if the skipSaleableCheck is set to true.

Related Topic