Magento receives dropdown lists of products

I linked the sku bundle product to a simple piece.

Now I'm trying to find the product options in the kit.

$selectionCollection = $bundled_product->getTypeInstance(true)->getSelectionsCollection(
      $bundled_product->getTypeInstance(true)->getOptionsIds($bundled_product), $bundled_product 

I used the code above, but it returns me the whole simple product in the kit. But I need an array of parameters. From the options I want an array of choices so that I can iterate and create a drop-down menu for each related option

I looked into the select.phtml kernel

<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 a similar thing to view.phtml. However, I cannot access these methods. Does anyone know how I do this.

+4
source share
1 answer
$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();
    }
}
+11
source

All Articles