在 MiniCart Magento 中获取可配置选项

Get Configurable Options in MiniCart Magento

我需要显示可配置选项,我有这个代码

           $productOptions = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct()); 
           if($productOptions){
               if(isset($productOptions['options'])){
                    foreach($productOptions['options'] as $_option){
                         $productser = $_option['option_id'].','.$_option['option_value'];                           
                    } 
               }
                $superAttrString ='';
                if(isset($productOptions['info_buyRequest']['super_attribute'])){
                    foreach($productOptions['info_buyRequest']['super_attribute'] as $key => $_superAttr){ 
                        $superAttrString .= '&super_attribute'.'['.$key.']='.$_superAttr;                                             
                    }      
                }
                if($superAttrString):
                    $superAttrString.'&qty=1';
                endif;
           }

            $html .='<span class="label">Configurable Options: # '.$superAttrString.'</span>

现在 $superAttrString 变量的结果是

&super_attribute[92]=3&super_attribute[135]=5 我怎样才能在那里显示标签而不是 ID's

非常感谢

我认为在您的 foreach 中,这样的事情应该可行:

foreach($productOptions['info_buyRequest']['super_attribute'] as $key => $_superAttr){ 
    $attr = Mage::getModel('catalog/resource_eav_attribute')->load($key);
    $label = $attr->getSource()->getOptionText($_superAttr);
    $superAttrString .= '&super_attribute'.'['.$attr->getAttributeCode().']=' . $label;                                             
}