在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的

非常感谢

我认为这样的东西应该在你的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;                                             
}