I am trying to get the available size based on color
$attValConfig = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
It is returning both color and size but I want color first after that sizes based on color.
foreach($attValConfig as $attValConfigSingle) {
var_dump($attValConfigSingle["label"]);
//Output Color and Size
}
Best Answer
You could get those options by getting the available child products and matching the option values like this:
If you are planning to use this on configurable products pages the price will not update anymore. If you are aiming for that functionality you should take a look at the function
getJsonConfig
inMage_Catalog_Block_Product_View_Type_Configurable
and refactor that to your needs.