I have associated a bundle product sku with simple product.
Now I am trying to fetch bundled product options.
$selectionCollection = $bundled_product->getTypeInstance(true)->getSelectionsCollection(
$bundled_product->getTypeInstance(true)->getOptionsIds($bundled_product), $bundled_product
I have used the above code but it returns me all simple product under bundled. But i want the array of options. From options i want array of selections so that i can iterate and create dropdown for every bundled option
I looked into the core select.phtml
<select onchange="bundle.changeSelection(this)" id="bundle-option-<?php echo $_option->getId() ?>" name="bundle_option[<?php echo $_option->getId() ?>]" class="bundle-option-<?php echo $_option->getId() ?><?php if ($_option->getRequired()) echo ' required-entry' ?> bundle-option-select change-container-classname">
<option value=""><?php echo $this->__('Choose a option') ?></option>
<?php foreach ($_selections as $_selection): ?>
<option value="<?php echo $_selection->getSelectionId() ?>"<?php if ($this->_isSelected($_selection)) echo ' selected="selected"' ?><?php if (!$_selection->isSaleable()) echo ' disabled="disabled"' ?>><?php echo $this->getSelectionTitlePrice($_selection, false) ?></option>
<?php endforeach; ?>
</select>
I want to replicate similar thing on view.phtml. However i am not able access those methods. Does anyone has idea how do i do that.
$optionCollection = $product->getTypeInstance()->getOptionsCollection();
$selectionCollection = $product->getTypeInstance()->getSelectionsCollection($product->getTypeInstance()->getOptionsIds());
$options = $optionCollection->appendSelections($selectionCollection);
foreach( $options as $option )
{
$_selections = $option->getSelections();
foreach( $_selections as $selection )
{
echo $selection->getName();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With