Pages

Tuesday, June 25, 2013

Fetch configurable product attributes values

Getting all options of a specific magento configurable product attribute is fairly easy:



getAttribute('catalog_product', 'color');
foreach ($attribute->getSource()->getAllOptions(true) as $option) {
echo $option['value'] . ' ' . $option['label'] . "\n";
}
?>




get options and their values which are applicable to a particular configurable product



getTypeInstance(true)->getConfigurableAttributesAsArray($product);
$attributeOptions = array();
foreach ($productAttributeOptions as $productAttribute) {
foreach ($productAttribute['values'] as $attribute) {
$attributeOptions[$productAttribute['label']][$attribute['value_index']] = $attribute['store_label'];
}
}
?>

No comments:

Post a Comment