This post is just a small snippet that will help you to get all products that are used do construct any bundle product.
Of course, I’m not sure how useful can it be as is, so if you need optimized version of it, you will need to play with it for a while.
You will need some basic knowledge of PHP language in order to fix formatting issues that you may (not saying that you will) encounter due strange behavior of code display plugin in wordpress.
I tried to find it on google few days ago and I had no luck, so if anybody has better solution, please comment.
Here we go:
< ?php
$bundled_product = new Mage_Catalog_Model_Product();
$bundled_product->load(YOUR_BUNDLED_PRODUCT_ID);
$selectionCollection = $bundled_product->getTypeInstance(true)->getSelectionsCollection(
$bundled_product->getTypeInstance(true)->getOptionsIds($bundled_product), $bundled_product
);
$bundled_items = array();
foreach($selectionCollection as $option)
{
$bundled_items[] = $option->product_id;
}
print_r($bundled_items);
?>
That easy ^_^



Hello,
What is the purpose of $option_collection? Is it important to call getOptionsCollection()? The result is assigned and never used.
Hi clockworkgeek,
U R right, I have fixed that, tnx for noticing.
Somehow I overlooked it when I was pulling code out of the original context XD
Mage guys should create a getBundledProducts() for a product that isBundled(). It would be easier for everyone.
if($product->hasCustomOptions()){
$customOption = $product->getCustomOption(‘bundle_selection_ids’);
$selectionIds = unserialize($customOption->getValue());
$selections = $this->getSelectionsByIds($selectionIds, $product);
foreach ($selections->getItems() as $selection)
$ids[] = $selection->getId();
}
great post as usual!
hi i want to show Bundle Product Options on Product Listing page Can any one help me?
Hi guys, is possible to add a non simple product in a bundle product in magento?
that is necessary for my work .
F.e. I sell football shirt
I sell letters and number for printings
So i create ( f.e. ) grouped product for a name of player ( eg. Lampard 8 is composed by 1 L – 2 A – 1 M – 1 P – 1 R – 1 D and 1 x number 8 ) and all chelsea players , so I can control stock of letters
Then I create a chelsea shirt, with sizes apart and include players by adding the previous grouped product or another bundle with all players
Thanks for any help
Thank you for this Very usefull code.
How do you also get the disabled ones as GetSelectionCollection() seems to return only enabled items ?
regards
Hi was just reading this as I was desperate to find a solution, had the options but not the quantities and product names so I used this:
// For bundle product
$options = $selectionCollection = $_product->getTypeInstance(true)
->getSelectionsCollection(
$_product->getTypeInstance(true)->getOptionsIds($_product),
$_product
);
foreach($options as $option){
echo $option->getSelectionQty()*1 . ‘ x ‘ . $option->getName() . ”;
}
How do I know which options is drop-down or select or may be checkbox type?
Not sure really I guess there would be something in the $option model? Use print_r to see what is in there