Here is an example how to access the is salable state or the stock quantity of all associated child products.
this first method is simply to fetch the child product ids from the bundled product.
function getBundledProductChildIds(Mage_Catalog_Model_Product $product)
{
$childrenIds = [];
if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
$childrenIds = array_reduce(
$product->getTypeInstance(true)->getChildrenIds($product->getId()),
function (array $reduce, $value) {
return array_merge($reduce, $value);
}, []);
}
return $childrenIds;
}
The next example gives you the in stock or out of stock for each child product.
$bundledProduct = Mage::getModel('catalog/product')->load(BUNDLED_PRODUCT_ID);
// Just get the is salable state of the child products
$childProducts = Mage::getResourceModel('catalog/product_collection')
->addIdFilter(getBundledProductChildIds($bundledProduct));
foreach ($childProducts as $child) {
printf("%s -> %s stock\n", $child->getId(), ($child->getIsSalable() ? 'in' : 'out of'));
}
The final example gives you the stock qty of each child product.
Note that the key difference is that the require_stock_items
flag is set on the collection before it is loaded.
$bundledProduct = Mage::getModel('catalog/product')->load(BUNDLED_PRODUCT_ID);
// Get the inventory qty of each child item
$childProducts = Mage::getResourceModel('catalog/product_collection')
->addIdFilter(getBundledProductChildIds($bundledProduct))
->setFlag('require_stock_items', true);
foreach ($childProducts as $child) {
printf("%s -> stock qty: %d\n", $child->getId(), $child->getStockItem()->getQty());
}
printf("Total stock item qty sum: %d\n", array_reduce(
$childProducts->getItems(),
function ($sum, $child) {
return $sum + $child->getStockItem()->getQty();
}, 0));
printf("Highest stock qty: %d\n", array_reduce(
$childProducts->getItems(),
function ($max, $child) {
return max($max, $child->getStockItem()->getQty();
}, 0));
That should hopefully enable you to get what you need.
Magento has default feature of Bundle product price to show on the listing and product view page. It should be shown the min price on the listing page like,
Starting at $5 or as low as $5, and on the product page, the user can see the full price as there is the bundle.
Best Answer
For Simple
override on below path
For Bundle
override on below path