Question

Data that have:

Super attribute id, Super option selected attribute id

And I want to get the value entered in the option of a product.

Each product has the same super attribute, what do is change the settings for the same product in each option has a different value

In general, I need to get the option price of supert attribute id of super attribute option selected id of product

I generated this code below solves, but this too bad = (

$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 />';
    }
}
Was it helpful?

Solution 2

Code Amit Bera, helped me down the resolution that solved my problem

$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'];
                }
            }
        }
    }

}

OTHER TIPS

Try the below code....

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

                }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top