Magento – how to get all attributes name and value from configurable product

attributesconfigurable-productmagento-1.9product

i have configurable product made from different atrributes like : color , size, fabric

now i wrote code below to get all simple product from configurable products

$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($this->getProduct());
$simple_collection = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();

foreach($simple_collection as $simple_product){
    echo "<tr><td>". $simple_product->getName() ."</td><td>".$simple_product->getSku()."</td><td>".Mage::helper('core')->currency($simple_product->getPrice())."</td><td>".$simple_product->getQty()."</td></tr>";
}

1:now i want to get all atributes from which configurable product is made and there respective value for simple products, ie value of color, size and fabric for all products

2:qty show blank why ??

Best Answer

load config product:

   $currentProduct = Mage::getModel('catalog/product_type_configurable')->setProduct($this->getProduct());;

    $products = array();

        $skipSaleableCheck = Mage::helper('catalog/product')->getSkipSaleableCheck();

getting all all simple products

    $allProducts = $conf->getTypeInstance(true)
            ->getUsedProducts(null, $conf);

    foreach ($allProducts as $product) {
        $products[] =  $product;
    }
        getting all configurable attribute of that products
        $AllowAttributes=$conf->getTypeInstance(true)
            ->getConfigurableAttributes($conf);

Getting config attribute for this product by attribute value id and label

    foreach ($products as $product) {
       foreach ($AllowAttributes as $attribute) {

            $productAttribute   = $attribute->getProductAttribute();
            $productAttributeId = $productAttribute->getId();
            $attributeValue     = $product->getData($productAttribute->getAttributeCode());
            /* Simple Product data */

            /* getting option text value */
            if ($productAttribute->usesSource()) {
                 $MYabel = $productAttribute->getSource()->getOptionText($attributeValue );
            }else{
                 $MYabel='';
            }


        }
    }