Magento Coding Solutions

How to get all super attribute options for a configurable item in Magento / How to get All option by Configurable product Id

/*****************************************************************
How to get Configurable product Option by product Id
****************************************************************
require_once '../app/Mage.php';
Mage::app();
$product=Mage::getModel('catalog/product')->load(18);
/*$configurableAttributeCollection=$product->getTypeInstance()->getConfigurableAttributes();

foreach($configurableAttributeCollection as $attribute){
$attributeid = $attribute->getProductAttribute()->getId();
//echo "super:->".$attributeid."";
  $new = $attributeid;
} */



$productAttributeOptions = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
$attributeOptions = array();


foreach ($productAttributeOptions as $productAttribute) {
echo $productAttribute['label']."";
echo $productAttribute['attribute_id']."-------"."";

foreach ($productAttribute['values'] as $attribute) {

echo "id:".$attribute['value_index']."price:".$attribute['pricing_value']. $attribute['store_label']."";

}

}
?>




1 comment: