0

Front end configurable product is showing a consistent "Out of stock" with a correctly set up configurable product. The following is what i have triple checked:

  • Configurable product is visible and set to in stock
  • Configurable product Manage stock is yes and qty increments no.
  • Configurable product has three associated simple products all are enabled with non-zero qty's and in stock.
  • All simple products are set to not visible individually.
  • Attribute is setup correctly with a Global scope and is applied to both simple and configurable products.
  • Another test configurable product was made from scratch to confirm it was not a one off issue.

I am 100% certain the issue is not with the creation of the configurable product itself and am putting it down to possibly a magento core code issue? However i will note none of the core magento code has been modified. My own custom theme is being used with appropriate layouts and templates. Perhaps i haven't loaded a specific javascript snippet or something in one of my templates? im not too sure of how the configurable product is any different from a standard product loading the stock status (which yes is working for my normal simple products).

Any help is much appreciated.

0

Update:

For those who may have the same issue, i have found the solution to my problem. The issue was i had made my view.phtml template myself and therefore i was loading the product qty using:

$qty = (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();

And therefore my configurable products was not loading the qty of the child products so $qty was returning back as 0.

To fix this i added the following check for configurable products and if at least one of the associated children products had a non zero stock i returned in stock.

$config_qty = 0;
//load parent product "$product"
if($_product->getTypeId() == 'configurable'){
    $childProducts = Mage::getModel('catalog/product_type_configurable')
            ->getUsedProducts(null,$_product);

    // now get qty from collection
    $qtyModel = Mage::getModel('cataloginventory/stock_item');
    foreach($childProducts as $key => $child){
        $childQty[$key] = $qtyModel->loadByProduct($child)->getQty();
        if($childQty[$key] > 0) {
            $config_qty++;
        }
    } 

    if ($config_qty > 0) :
        echo $this->__('<font color="#72d144">In Stock</font>');
    else :
        echo $this->__('<font color="#e64209">Out of stock</font>');
    endif;
}

To improve this id rather be able to have some sort of ajax where it determined when the user has selected an attribute and display the corresponding stock level for that child product.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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