2013-10-22 2 views
4

번들 제품 sku를 간단한 제품과 연결했습니다.magento 번들 제품 드롭 다운 받기

이제 번들로 제공되는 제품 옵션을 가져 오려고합니다.

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

위 코드를 사용했지만 번들로 제공된 모든 단순 제품을 반환합니다. 하지만 옵션 배열이 필요합니다. 내가 반복하고 나는 핵심 select.phtml 내가 view.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> 

들여다 모든 번들 옵션

에 대한 드롭 다운을 만들 수 있도록 옵션에서 나는 선택의 배열을합니다. 그러나 나는 그 방법에 액세스 할 수 없습니다. 누구나 어떻게 할 수 있는지 알고 있습니다.

답변

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

감사합니다. 지난 3 시간 동안 이것을 얻으려고 노력했습니다! $ options = $ optionCollection-> appendSelections ($ selectionCollection); 트릭을 했어! –

관련 문제