1

Is the best way to build up an array of attributes from a configurable

if($_product->getTypeId() == "configurable")
{                   
   $simpleProducts = $_product->getTypeInstance(true)->getUsedProductCollection($_product);

   $attributeOptions = array();
   foreach ($simpleProducts as $simpleProduct)
   {
       $myproduct = Mage::getModel('catalog/product')->load($simpleProduct->getId());
       $baseColour = $myproduct->getAttributeText('basecolour'); 
       $attributeOptions[] = $baseColour
    }
}
2
  • have you only one attribute? – Amit Bera Oct 28 '14 at 12:33
  • The product has loads of custom attributes but yes I only want to get 1 – Goose84 Oct 28 '14 at 20:17
1

You could try the function getConfigurableAttributesAsArray. This function is on the object Mage_Catalog_Model_Product_Type_Configurable. It should take in a product and return an array of all the configurable attributes attached to the product.

The other options is to build a product collection using getUsedProductCollection and then add the attribute you need to the select.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.