2014-03-28 59 views
3

數據有:如何獲取超級屬性的值?

超級屬性ID, 超級選項中選擇屬性ID

而且我想在一個產品的選項輸入的值。

每個產品都有相同的超級屬性,是什麼做的是改變了設置在每個選項相同的產品具有不同的值

在一般情況下,我需要得到超級屬性的supert id屬性的期權價格產物

的選項選擇的ID我生成下面解決了這個代碼,但是這太糟糕=(

$produto_cor = Mage::getModel('catalog/product')->load($id_produto); 
$produto_cor_options = $produto_cor->getTypeInstance(true)->getConfigurableAttributesAsArray($produto_cor); 
foreach($produto_cor_options as $options){ 
    $atributo_cor = $options['values']; 
    foreach ($atributo_cor as $options2){; 
     echo $options2['pricing_value'] . '<br />'; 
    } 
} 
+0

問題不明確.... –

+0

我有顏色的屬性配置產品的分辨率,該屬性具有與每個可以通過多種方式有一個額外的價值 我想獲得額外的價值,因爲我已經給找到id和attributo選項的id你想要的附加值 – Dexxtz

回答

-2

代碼阿米特·貝拉,幫我失望的是解決我的問題

$cor = addslashes($_GET['cor']); 
$cor_selecionada = addslashes($_GET['cor_selecionada']); 
$configProd = Mage::getModel('catalog/product')->load($id_produto); 
$AllowAttributes=$configProd->getTypeInstance(true)->getConfigurableAttributes($configProd); 
$optionPrices = array(); 

foreach ($AllowAttributes as $attribute) {     
    $productAttribute = $attribute->getProductAttribute(); 
    if($productAttribute->getId() == $cor){ 
     $prices = $attribute->getPrices(); 
     if (is_array($prices)) { 
      foreach ($prices as $value) { 
       if($value['value_index'] == $cor_selecionada){ 
        echo $value['pricing_value']; 
       } 
      } 
     } 
    } 

} 
1

嘗試下面的代碼....

$configProd=Mage::getModel('catalog/product')->load($config_proid); 
      $AllowAttributes=$configProd->getTypeInstance(true) 
       ->getConfigurableAttributes($configProd); 
      $optionPrices = array(); 
       $_attribute_id = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product','color')->getId(); 

       foreach ($AllowAttributes as $attribute) { 
       $productAttribute = $attribute->getProductAttribute(); 
       $attributeId = $productAttribute->getId(); 
       // run rest of when color attribute is looped. 
       if($productAttribute->getId()!=$_attribute_id){ 
       continue; } 


       $prices = $attribute->getPrices(); 
       if (is_array($prices)) { 
        foreach ($prices as $value) { 

//$value['value_index'] is option id 
         $optionPrices[$value['value_index']]=$value; 
        } 
       } 

       }