2

I'm trying to display the bundled product in the category product list on the frontend even when the simple product it concists of is out of stock. I only want to hide the add to cart button.

I've looked into changing the Mage_Bundle_Model_Product_Type class to return true on the stock check but that is not really a solution.

Is there a way to do this in a clean way either trough settings or by extending as little core code as possible?

2 Answers 2

1

You could create some method in one of the helpers

public function isBundleAvailable($_product) {
    $bundle = Mage::getModel('catalog/product')->load($_product->getId());
    $selectionCollection = $bundle->getTypeInstance(true)->getSelectionsCollection(
        $bundle->getTypeInstance(true)->getOptionsIds($bundle), $bundle
    );
    $items = array();

    foreach($selectionCollection as $option) {        
        $isAvailable = $option->getStockItem()->getIsInStock();
        if (!$isAvailable) {
            return false;
        }
    }
     return true;
}

Then in template you could use something like that:

<?php if (Mage::helper('my_module')->isBundleAvailable($_product)): ?>
    <?php //display add to cart button
<?php endif ?>
0

The bundled product should be visible when you have the option: System > Configuration > Inventory > Stock Options > Display Out of Stock Products set to Yes. All out of stock products are listed but you have no Add to Cart button.

2
  • already tried that and it doesn't work for bundle products Commented Feb 7, 2013 at 12:35
  • It's working for me on a plain 1.7 install with the test data. Commented Feb 12, 2013 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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