Magento获得捆绑的产品下拉菜单


magento get bundled product dropdowns

我将捆绑产品 SKU 与简单产品相关联。

现在我正在尝试获取捆绑的产品选项。

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

我已经使用了上面的代码,但它向我返回捆绑的所有简单产品。但我想要一系列选项。从选项中,我想要选择数组,以便我可以为每个捆绑的选项迭代和创建下拉列表

我查看了核心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>

我想在view.phtml上复制类似的东西。但是我无法访问这些方法。有没有人知道我该怎么做。

$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();
    }
}